Answered by:
using update panel with dropwn to display value in grid textbox

Question
-
User-1474096950 posted
i have a grid with dropdown and textbox
on dropdown selected indec change i get the value from database & display in textbox
but it causes whole page postback
the textbox has javascript onblur event
if i place the dropwndown in updatepanel there is no page refresh but the textbox doesnot get any valueSaturday, March 1, 2014 8:54 AM
Answers
-
User-417640953 posted
if i place the dropwndown in updatepanel there is no page refresh but the textbox doesnot get any valueHi svibuk,
Thank you post the issue to asp.net forum.
From your description, I see you want to update the textbox out of the updatepanel when the dropdownlist postback which in the updatepanel.
For this issue, I suggest you use the javascript to complete it like below demo:
<head runat="server"> <title></title> <script> function pageLoad(sender,args) { if (args.get_isPartialLoad()) { document.getElementById("<%=TextBox1.ClientID%>").value = document.getElementById("<%=HiddenValueForTextBox.ClientID%>").value; } } </script> </head> <body> <form id="form1" runat="server"> <div> <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="true" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged"> <asp:ListItem Selected="True" Text="one" Value="one"></asp:ListItem> <asp:ListItem Text="two" Value="two"></asp:ListItem> <asp:ListItem Text="three" Value="three"></asp:ListItem> </asp:DropDownList> <asp:HiddenField ID="HiddenValueForTextBox" runat="server" /> </ContentTemplate> </asp:UpdatePanel> </div> </form> </body>
code behind:
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) { this.HiddenValueForTextBox.Value = "somedata";//suppose comes from database. }
Hope this helps, thanks.
Best Regards!
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Tuesday, March 4, 2014 2:06 AM
All replies
-
User398825048 posted
Post your code so that it can be seen how you are getting the value and whether you are correctly assigning it to the textbox or not.
Sunday, March 2, 2014 11:33 AM -
User-417640953 posted
if i place the dropwndown in updatepanel there is no page refresh but the textbox doesnot get any valueHi svibuk,
Thank you post the issue to asp.net forum.
From your description, I see you want to update the textbox out of the updatepanel when the dropdownlist postback which in the updatepanel.
For this issue, I suggest you use the javascript to complete it like below demo:
<head runat="server"> <title></title> <script> function pageLoad(sender,args) { if (args.get_isPartialLoad()) { document.getElementById("<%=TextBox1.ClientID%>").value = document.getElementById("<%=HiddenValueForTextBox.ClientID%>").value; } } </script> </head> <body> <form id="form1" runat="server"> <div> <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="true" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged"> <asp:ListItem Selected="True" Text="one" Value="one"></asp:ListItem> <asp:ListItem Text="two" Value="two"></asp:ListItem> <asp:ListItem Text="three" Value="three"></asp:ListItem> </asp:DropDownList> <asp:HiddenField ID="HiddenValueForTextBox" runat="server" /> </ContentTemplate> </asp:UpdatePanel> </div> </form> </body>
code behind:
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) { this.HiddenValueForTextBox.Value = "somedata";//suppose comes from database. }
Hope this helps, thanks.
Best Regards!
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Tuesday, March 4, 2014 2:06 AM