Writing javascript for dropdownlist selectedIndexChange

  • Thread starter Thread starter MBhat
  • Start date Start date
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
 
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
 
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
 
Back
Top