473,395 Members | 1,987 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

adding onchange javascript that fires after doPostBack ?

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.
Nov 18 '05 #1
3 4096
"Mad Scientist Jr" <us*************@yahoo.com> wrote in message
news:7a**************************@posting.google.c 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
Nov 18 '05 #2
> 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?
Nov 18 '05 #3
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" <us*************@yahoo.com> wrote in message
news:7a**************************@posting.google.c 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.

Nov 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: SM | last post by:
Hi , I am using a window.open function to popup window in my C# code in this manner . Response.Write("<SCRIPT language=\"javascript\">"); Response.Write(String.Format("window.open(\"{0}...
1
by: richardscheff | last post by:
Video selector works for IE but not other browsers. for not IE <object ID='Player' data="video/dodgeball.wmv" type="video/x-ms-wmv" width="320" height="280"> <param name="filename"...
7
by: Bruno Alexandre | last post by:
Hi Guys, I'm having a HUGE problem with Javascript under IE, the code below belongs to a page http://filterqueen.brinkster.net/test.aspx it works fine under Firefox, but not in IE... does...
2
by: donald | last post by:
I have a function called populate which populate a select box. I need it to run when a different select box value is chnage. So I need the event onChange. But i need to pass it two var to. how...
2
by: Ken Fine | last post by:
In code, I'm adding javascript attributes to form elements on an ASP.NET page: body.Attributes.Add("onClick", "highlight(event);"); body.Attributes.Add("onKeyUp", "highlight(event);");...
14
by: ap.sakala | last post by:
Hello, How the heck should I make this simple summering of a data without a submit button? Like in an excel sheet I would like to have a couple of cells in a column and as soon the visitor...
1
by: Mel | last post by:
Is it possible to add an OnChange call AFTER the form is created ? i tried something like: document.getElementById('V122').onChange=callback(); my callback is: function callback() { var...
1
by: Mel | last post by:
I would like to add onChange to a select only if a javascript function zzz exist. can this be done ? example is highly appreciated
1
by: javelin | last post by:
I have this code to add an onChange event to a select control: catid.attributes.value= "FilterByCatID();"; alert(catid.attributes.value); The alert box confirms that the event has been set,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.