Answered by:
Issue with UpdatePanel

Question
-
User1769015664 posted
Why does the following code make the entire screen flash when either of the dropdown is clicked?
<asp:UpdatePanel ID="UpdatePanel5" runat="server" UpdateMode="Conditional"> <ContentTemplate> <td style="width:10%;"><asp:DropDownList ID="DropDownList1" runat="server" Width="95%" AutoPostBack="true" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged"></asp:DropDownList></td> <td style="width:10%;"><asp:DropDownList ID="DropDownList2" runat="server" Width="95%" AutoPostBack="true" OnSelectedIndexChanged="DropDownList2_SelectedIndexChanged"></asp:DropDownList></td> </ContentTemplate> </asp:UpdatePanel>
Wednesday, July 19, 2017 7:54 PM
Answers
-
User-1838255255 posted
Hi NJ2,
About how to use dropdownlist inside updatepanel, I make a sample, the page is not refresh when I click the dropdownlist. Please check the following code:
Sample Code:
<asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <asp:UpdatePanel ID="upSetSession" runat="server"> <ContentTemplate> <asp:DropDownList ID="ddlMyList" runat="server" OnSelectedIndexChanged="ddlMyList_SelectedIndexChanged" AutoPostBack="true"> <asp:ListItem>Select One</asp:ListItem> <asp:ListItem>Maybe</asp:ListItem> <asp:ListItem>Yes</asp:ListItem> </asp:DropDownList> </ContentTemplate> <Triggers> <asp:AsyncPostBackTrigger ControlID="ddlMyList" EventName="SelectedIndexChanged" /> </Triggers> </asp:UpdatePanel>
protected void Page_Load(object sender, EventArgs e) { } protected void ddlMyList_SelectedIndexChanged(object sender, EventArgs e) { }
Best Regards,
Eric Du
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Thursday, July 20, 2017 2:20 AM
All replies
-
User-1838255255 posted
Hi NJ2,
About how to use dropdownlist inside updatepanel, I make a sample, the page is not refresh when I click the dropdownlist. Please check the following code:
Sample Code:
<asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <asp:UpdatePanel ID="upSetSession" runat="server"> <ContentTemplate> <asp:DropDownList ID="ddlMyList" runat="server" OnSelectedIndexChanged="ddlMyList_SelectedIndexChanged" AutoPostBack="true"> <asp:ListItem>Select One</asp:ListItem> <asp:ListItem>Maybe</asp:ListItem> <asp:ListItem>Yes</asp:ListItem> </asp:DropDownList> </ContentTemplate> <Triggers> <asp:AsyncPostBackTrigger ControlID="ddlMyList" EventName="SelectedIndexChanged" /> </Triggers> </asp:UpdatePanel>
protected void Page_Load(object sender, EventArgs e) { } protected void ddlMyList_SelectedIndexChanged(object sender, EventArgs e) { }
Best Regards,
Eric Du
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Thursday, July 20, 2017 2:20 AM -
User1769015664 posted
Thanks Eric but it doesn't work right. I have posted this question weeks ago and have already tried your solution above previous and just tried again. It adds tow new dropdowns right above when I click on one of the dropdowns. Please see attached screenshot.
Thursday, July 20, 2017 5:02 AM -
User-1838255255 posted
Hi NJ2,
According to your description, I think this new issue(Extra Dropdownlist created when click Dropdownlist) is not related your previous issue(screen flash).
This issue is related to the dropdownlist click or selectchange or Page_Load event. So you need change these events if have code to create a new dropdownlist.
Best Regards,
Eric Du
Thursday, July 20, 2017 6:21 AM -
User1769015664 posted
Eric,
Adding the Trigger has always been issue in my case and this is the 2nd post within 4 weeks. I do not have any code
This issue is related to the dropdownlist click or selectchange or Page_Load event. So you need change these events if have code to create a new dropdownlist.All I have in SelectChange is [string sString ="Got it"]
Thursday, July 20, 2017 2:09 PM -
User1769015664 posted
Eric, there was an obvious mistake in my code above; the update panel needed to be inside <TD> element.
It seems to be working fine; I will give you credit for your answer to actual question.
Thursday, July 20, 2017 6:43 PM