Writing javascript for dropdownlist selectedIndexChange

M

MBhat

Hello,

I have a dropdownlist server control.On selectedIndexChange I do some
functionality. In addtion to this I need to check for something else. To
do this I have to use javascript function to display confirmation alert.
How can I use the javascript confirmation alert in code behind?

any help?

Thanks
Mangala Bhat
 
S

Steve C. Orr [MVP, MCSD]

You can execute a line of code like this when you want a message box to be
displayed.
(This writes out the necessary client side javascript to your HTML page to
make the alert pop up as soon as the page is sent to their browser.)

RegisterStartupScript("startupScript", "<script
language=JavaScript>alert('This is my message.');</script>");

Here's more info:
http://msdn.microsoft.com/library/d...mWebUIPageClassRegisterStartupScriptTopic.asp

Here are a couple controls you might find to be useful:
http://www.metabuilders.com/Tools/ConfirmedButtons.aspx
http://www.jttz.com/msgbox/index.htm
 
M

MBhat

Hello,

Let me be more clear about my problem.

I have a dropdownlist server control. I have written SelectedIndexChange
method for this. Now I also need to write a javascript function which
has a confirmation message in it for the same SelectedIndexChange
method.

I wrote it like this
mDrpCounties.Attributes.Add("onchange", "CheckAlert();")

I noticed one thing here..The first time when the selectedIndexChange
method is called the javascript doesn't fire. but the second time when
its done, javascript fires.

Why is that??? Can you tell me??

I tried to do RegisterStartupScript,RegisterClientScriptBlock but
nothing is working.

Thanks
MBhat
 

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,007
Latest member
obedient dusk

Latest Threads

Top