468,514 Members | 1,075 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,514 developers. It's quick & easy.

Writing javascript for dropdownlist selectedIndexChange



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

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #1
2 4821
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/de...criptTopic.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

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
Hire top-notch developers at http://www.able-consulting.com
"MBhat" <ma*****@devx.com> wrote in message
news:Oa**************@TK2MSFTNGP10.phx.gbl...


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

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 18 '05 #2

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
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Paraki | last post: by
1 post views Thread by Ravi | last post: by
1 post views Thread by ProSAAP | last post: by
4 posts views Thread by Yahya Saad | last post: by
2 posts views Thread by Kevin | last post: by
3 posts views Thread by Kim | last post: by
1 post views Thread by fmendoza | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.