|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
DropDownList select: first visible a label, then post backHi;
When a DropDownList item is selected, I want to first make a hidden label visible, then have it post back. The label says "processing..." by the list and will be hidden again when the page is returned in 2 - 4 seconds. How can I do this? You might program the onchange event of the <select> tag that is rendered by
the <asp:DropDownList> control to execute a JavaScript that turns a <span> visible and causes a hidden button click event that would post back to the server instead of having the DropDownList postback set to true. Show quoteHide quote "David Thielen" wrote: > Hi; > > When a DropDownList item is selected, I want to first make a hidden label > visible, then have it post back. The label says "processing..." by the list > and will be hidden again when the page is returned in 2 - 4 seconds. > > How can I do this? > > -- > thanks - dave > david_at_windward_dot_net > http://www.windwardreports.com > Hi;
I just tried this but I think I'm doing something wrong. Does anyone have a javascript function that does this or knows of a url showing it? Show quoteHide quote "Phillip Williams" wrote: > You might program the onchange event of the <select> tag that is rendered by > the <asp:DropDownList> control to execute a JavaScript that turns a <span> > visible and causes a hidden button click event that would post back to the > server instead of having the DropDownList postback set to true. > > -- > HTH, > Phillip Williams > http://www.societopia.net > http://www.webswapp.com > > > "David Thielen" wrote: > > > Hi; > > > > When a DropDownList item is selected, I want to first make a hidden label > > visible, then have it post back. The label says "processing..." by the list > > and will be hidden again when the page is returned in 2 - 4 seconds. > > > > How can I do this? > > > > -- > > thanks - dave > > david_at_windward_dot_net > > http://www.windwardreports.com > > It is not going to be one simple script. It might take an hour to patch
together a few of them, so I will leave you with links and you have to do the hour's work. 1) onchange event: http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/events/onchange.asp 2) save the clientID of the label control to the browser javascript during the PreRender event like I did in this sample: http://www.webswapp.com/codesamples/viewsource.aspx?file=~/codesamples/aspnet20/textbox/default.aspx 3) create a button and style with cssClass="Hidden" where Hidden is defined as display = "none" 4) at the end of your javascript call the Click method of the Button (you need the ClientID of the button to be sent in step#2 5) Program the Button click event to do the equivalent of what the dropdownlist selectedIndexChanged would have done. Show quoteHide quote "David Thielen" wrote: > Hi; > > I just tried this but I think I'm doing something wrong. Does anyone have a > javascript function that does this or knows of a url showing it? > > -- > thanks - dave > david_at_windward_dot_net > http://www.windwardreports.com > > > > "Phillip Williams" wrote: > > > You might program the onchange event of the <select> tag that is rendered by > > the <asp:DropDownList> control to execute a JavaScript that turns a <span> > > visible and causes a hidden button click event that would post back to the > > server instead of having the DropDownList postback set to true. > > > > -- > > HTH, > > Phillip Williams > > http://www.societopia.net > > http://www.webswapp.com > > > > > > "David Thielen" wrote: > > > > > Hi; > > > > > > When a DropDownList item is selected, I want to first make a hidden label > > > visible, then have it post back. The label says "processing..." by the list > > > and will be hidden again when the page is returned in 2 - 4 seconds. > > > > > > How can I do this? > > > > > > -- > > > thanks - dave > > > david_at_windward_dot_net > > > http://www.windwardreports.com > > > Hi Dave,
I agree with Phillip that you can register the client-side "onchange" event handler for the dropdownlist control. Also(you can also consider the <form>'s "onsubmit" event I mentioned in your former thread). Here is a simple test page which register a client-side "onchange" script handler for the dropdownlist to display a hidden html <div>: =========aspx template ============= ....................... <script language="javascript"> function before_postback() { document.getElementById("divWait").style.display = ""; } </script> </HEAD> <body> <form id="Form1" method="post" runat="server"> <table width="100%"> <tr> <td> <div id="divWait" style="DISPLAY:none">The data is being processed, please wait.................</div> </td> </tr> <tr> <td style="HEIGHT: 19px"> <asp:DropDownList id="lstItems" runat="server" AutoPostBack="True"> <asp:ListItem Value="aaa">aaa</asp:ListItem> <asp:ListItem Value="bbb">bbb</asp:ListItem> <asp:ListItem Value="ccc">ccc</asp:ListItem> <asp:ListItem Value="ddd">ddd</asp:ListItem> </asp:DropDownList> </td> </tr> ........................ =============================== =======code behind============= private void Page_Load(object sender, System.EventArgs e) { // Put user code to initialize the page here lstItems.Attributes["onchange"] = "before_postback();"; } private void lstItems_SelectedIndexChanged(object sender, System.EventArgs e) { System.Threading.Thread.Sleep(5000); Response.Write("<br/>SelectedIndexChanged...."); } ======================== Hope this also helps. Regards, Steven Cheng Microsoft Online Support Get Secure! www.microsoft.com/security (This posting is provided "AS IS", with no warranties, and confers no rights.)
RadioButtonList, MultiView, and JavaScript
formview with objectDataSource won't display data Web UserControl DropDownlist control event not working... bug with gridview.selectedvalue? How to refresh a dropdownlist inside a DetailsView? Create a word like doc from C#.NET Passing values between user controls in separate forms Menu control MenuItemClick does not fire. Hidden input field named "__EVENTVALIDATION" multiView vs panel |
|||||||||||||||||||||||