Triggering a javascript after postback from dropdownlist

C

Corobori

In my form my users are entering some data, one of them being a
dropdownlist. When an item is choosen from that dropdownlist I am
posting back to the server in order to retrieve some data from the
server that are part of the calculation on the client side.

I am using that javascript code also from other control of my form but
WITHOUT postback, in those cases it works fine like this
Me.myControlName.Attributes.Add("onchange", "ComputeValue();") The same
for the dropdownlist doesn't work well as the postback is doing its
job.

On another forum they say I could use a method called
RegisterClientScriptBlock; I searched the web for that topic and found
a lot of information about this but there is still one thing I am
missing: how I am going to say to run this script after coming back
from the postback. Most example are showing this method linked with a
button or other event manually triggered by a user but I think in my
case it is a touch different.

Jean-Luc
www.corobori.com
 
B

Brock Allen

I think what you really want is Page.RegisterStartupScript. This sets some
javascript (or a function you've declared via Page.RegisterScriptBlock) to
be called when the window/document loads.
 
C

Corobori

It was the way to go but I got trapped in another problem. It works
fine in the case I described above. My problem is now that when my user
is clicking the submit button I don't want that script to run: is there
a way to "unregister" the startup script (didn't find any reference to
that in Google) or (again) am I missing something here ?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,019
Latest member
RoxannaSta

Latest Threads

Top