Launch javascript confirmation box from DropdownList onSelectedInd

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Please help:
I have a DropdownList control that has a server-side onSelectedIndexChanged
event handler. Before this server-side event handler is run, I'd like a
client-side javascript confirmation box to appear for the user to select
whether or not to continue. I've tried adding an onselectedindexchanged
event handler in the Page.Load, I've tried Page.RegisterStartupScripts, but I
can't figure it out.

Here's my code:
ASPX Page:
<asp:DropDownList id="lstRecordsReturned" runat="server" AutoPostBack="True"
onSelectedIndexChanged="lstRecordsReturned_Click" />

So BEFORE the server-side handler method (lstRecordsReturned_Click) is
invoked, I want a javascript confirmation box to appear to the user first
allowing them to decide whether or not to proceed (i.e. return confirm('You
will lose unsaved changes, to proceed click OK, otherwise click cancel');).
I can't figure out the code to implement this type of functionality.

Any help is greatly appreciated.
 
Hi again :)
I posted a message before and I think it will solve this problem too.

lstRecordsReturned.Attributes.Add("OnChange",
"here_s_a_javascript_function");
 

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

Back
Top