By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,915 Members | 1,345 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,915 IT Pros & Developers. It's quick & easy.

Triggering a javascript after postback from dropdownlist

P: n/a
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

Nov 19 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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.

-Brock
DevelopMentor
http://staff.develop.com/ballen
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


Nov 19 '05 #2

P: n/a
You were right, I did it using the RegisterStartupScript and it worked.

Jean-Luc
www.corobori.com

Nov 19 '05 #3

P: n/a
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 ?

Nov 19 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.