Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > adding onchange javascript that fires after doPostBack ?

Reply
Thread Tools

adding onchange javascript that fires after doPostBack ?

 
 
Mad Scientist Jr
Guest
Posts: n/a
 
      07-15-2004
I have some javascript I would like to run after a doPostBack occurs:

onchange="javascript:__doPostBack('Text1','');[my JavaScript here]"

The doPostBack is being added dynamically by .NET when it renders the
control.

If anyone can tell me how to tell .NET to add the doPostBack BEFORE
any javascript in the onchange event, it would be most appreciated.
 
Reply With Quote
 
 
 
 
John Saunders
Guest
Posts: n/a
 
      07-15-2004
"Mad Scientist Jr" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) om...
> I have some javascript I would like to run after a doPostBack occurs:
>
> onchange="javascript:__doPostBack('Text1','');[my JavaScript here]"
>
> The doPostBack is being added dynamically by .NET when it renders the
> control.
>
> If anyone can tell me how to tell .NET to add the doPostBack BEFORE
> any javascript in the onchange event, it would be most appreciated.


See if RegisterOnSubmitStatement works for you:
(http://msdn.microsoft.com/library/de...-us/cpref/html
/frlrfSystemWebUIPageClassRegisterOnSubmitStatement Topic.asp).
--
John Saunders
johnwsaundersiii at hotmail


 
Reply With Quote
 
 
 
 
Mad Scientist Jr
Guest
Posts: n/a
 
      07-15-2004
> See if RegisterOnSubmitStatement works for you:
> (http://msdn.microsoft.com/library/de...-us/cpref/html
> /frlrfSystemWebUIPageClassRegisterOnSubmitStatement Topic.asp).


I found another workaround - the answer to the whole thing ended up
being: turn off Smart Navigation. It was screwing everything up. I
couldn't set the values of server side controls from javascript, among
other things. The values would stay the same they were when the form
first initilaized. When I turned off smart navigation, these problems
went away.

To force focus to a particular control, I found this worked:

In the HTML body:

<body onload="javascript:eval(document.Form1.txtJavascri pt.value);">

In control's Autopostback event:

Private Sub Text1_TextChanged(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Text1.TextChanged
'(your code here)
'...
txtJavascript.Value = "document.Form1." & Text2.UniqueID &
".focus();"
End Sub ' Text1_TextChanged


Note: I haven't tried registerClientsideScript (or is it
registerStartupScript? I forget at the moment). They didn't work when
I had smartnavigation on but might with it off. Is this preferable to
the above method?
 
Reply With Quote
 
bruce barker
Guest
Posts: n/a
 
      07-15-2004
there is no reliable way. :__doPostBack does a form.submit(), which just
adds a request to the message queue, its not processed synchronously. also
when the response comes, all running script is canceled.

the window unload event may be what you want - its called when the response
causes the current window to unload

-- bruce (sqlwork.com)

"Mad Scientist Jr" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) om...
> I have some javascript I would like to run after a doPostBack occurs:
>
> onchange="javascript:__doPostBack('Text1','');[my JavaScript here]"
>
> The doPostBack is being added dynamically by .NET when it renders the
> control.
>
> If anyone can tell me how to tell .NET to add the doPostBack BEFORE
> any javascript in the onchange event, it would be most appreciated.



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Simple composite control fires event fires first time but not second sellars.paul@googlemail.com ASP .Net Web Controls 3 05-13-2009 03:19 PM
adding onChange after form elements are created... Mel Javascript 1 04-03-2007 04:34 PM
adding extra code to the doPostBack function =?Utf-8?B?Q2VzYXI=?= ASP .Net 1 06-16-2005 10:17 PM
javascript confirm fires after deletion instead of before TJS ASP .Net 7 05-18-2005 01:55 AM
javascript dopostback fails =?Utf-8?B?RFNpcHA=?= ASP .Net 2 01-20-2005 08:40 AM



Advertisments