473,396 Members | 2,055 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,396 software developers and data experts.

Triggering a javascript after postback from dropdownlist

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
3 1645
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
You were right, I did it using the RegisterStartupScript and it worked.

Jean-Luc
www.corobori.com

Nov 19 '05 #3
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Allan M. | last post by:
I have a series of select boxes that must be populated client side, because they interact with each other. The design specification calls for these boxes to be updated without having to make a...
6
by: Olivier Matrot | last post by:
Hello, This has probably been asked several times, but It must be clarified for me. I would like to know why sometimes during a postback Page_Load is called after the function marked for...
8
by: Steve Schroeder | last post by:
For some reason I cannot get the OnSelectedIndexChanged event to fire for a listbox I have on a page. I'm able to populate the listbox with data from a stored procedure, but cannot trigger the...
1
by: Stuart Shay | last post by:
Hello All: I hava a ASP.NET Web Page where I want to change the visibility of a Dropdown, I want to avoid using Postback since the selection of the Dropdown choices is always the same. The Code...
5
by: robert | last post by:
I have a dropdownlist with the autopostback set to true. I want the user to be confirm whether they do indeed want to change the value, which on post back fires a server side event...
15
by: mc | last post by:
I'm writing an app for managing Task Lists, I'm trying to add some controls to a form that I can use to link tasks, my original intention was to: - Add two list boxes, one listing "all Tasks"...
0
by: =?Utf-8?B?cm9kY2hhcg==?= | last post by:
hey all, imagine this for a moment if you will: i have a row in a gridview that when it is in edit mode there is a column that contains a dropdownlist and 2nd column that contains a user control....
2
by: =?Utf-8?B?cm9kY2hhcg==?= | last post by:
hey all, i'm in a gridview edit row that has a DropDownList in one column and a status Label in the 2nd column. When i changed the value in the dropdownlist, there's a client-side javascirpt...
8
by: Dan | last post by:
Hi, i experimented with postback and viewstate. With this code, there are 2 dropdownlists created, one visible and with AutoPostBack true, the other not visible and no AutoPostBack, and one...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.