Asked by:
Update panel is not working

Question
-
User-394254955 posted
Iam working with a page i need update panel to avoid page refresh when textbox changed event fire .but when update panel is there the another textbox is not getting value of the textchanged event coding. the page using master page and some javascripts. when update panel or master page hide it is working good.
<tr>
<td colspan="2">Actual Programme fee(₹)
</td>
<td>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:TextBox ID="txtactualpfee" runat="server" Width="300px" AutoPostBack="true" OnTextChanged="txtactualpfee_TextChanged" ></asp:TextBox>
<asp:TextBox ID="txtdifferenc" runat="server" Width="300px" Enabled="false" placeholder="Difference in Programme fee"></asp:TextBox>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="txtactualpfee" EventName="TextChanged"/>
</Triggers>
</asp:UpdatePanel>
</td>
</tr>
<tr><td colspan="4">
<asp:GridView ID="grdtax" runat="server" Width="400px" CssClass="gridview" AutoGenerateColumns="False" DataKeyNames="taxid" ShowFooter="false" CellPadding="4" ForeColor="#333333" GridLines="none" OnRowDataBound="grdtax_RowDataBound" >
<Columns>
<asp:TemplateField >
<ItemTemplate>
<asp:Label ID="lbldesc" runat="server" Text='<%# Bind("taxdesc") %>'></asp:Label>
<asp:HiddenField ID="taxper" runat="server" Value='<%# Bind("taxper") %>' />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField >
<ItemTemplate>
<asp:TextBox ID="txttax" runat="server"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</td></tr>
<tr id="igst_tr" runat="server" visible="false">
<td colspan="2">
<asp:Label ID="l_igst" runat="server" Text="IGST @ 18%"></asp:Label></td>
<td>
<asp:TextBox ID="txtigst" runat="server" Width="300px" > </asp:TextBox></td>
</tr>
<tr>
<td colspan="2">Total Credit Note Amount (₹)
</td>
<td>
<asp:TextBox ID="txttotal" runat="server" Width="300px"></asp:TextBox>
</td></tr>
code behind
protected void txtactualpfee_TextChanged(object sender, EventArgs e) { int fee1=int.Parse(txtIprogramfee.Text); int fee2=int.Parse(txtactualpfee.Text); int difference = fee1-fee2; txtdifferenc.Text = difference.ToString(); if (!chkigst.Checked) { DateTime date = DateTime.ParseExact(txtdate.Text, "dd-MM-yyyy", CultureInfo.InvariantCulture); grdtax.DataSource = new academicinvoiceSP().gettaxdetails(date); grdtax.DataBind(); } else { igst_tr.Visible = true; float igst = 18; float actualfee = float.Parse(txtactualpfee.Text); float taxamount = actualfee * (igst / 100); txtigst.Text = taxamount.ToString(); txttotal.Text = (actualfee + taxamount).ToString(); }}
Monday, March 19, 2018 11:59 AM
All replies
-
User-1838255255 posted
Hi amrutha,
According to your description and code, i don't see where trigger txtactualpfee_TextChanged event, also i don't see any code about txtprogramfee_TextChanged event.
Also i am not clear which textbox is another textbox as you say?
I hope you could provide a complete code and detailed needs for us to check! This could better help you solve the problem.
Best Regards,
Eric Du
Tuesday, March 20, 2018 7:18 AM -
User-394254955 posted
when i type a value to textbox txtactualpfee ,it return a diffrence of program fee and actualpfee to textbox txtdiffrerenc tax calcuted value to txtigst also.
I dont want to refresh the page on textbox txtactualpfee thats why i used update panel but when i use update panel it the value is not getting to txttotal .
Iam using page with master page
there may be any conflict or something please tell me how to avoid such things and work my update panel perfectly
Tuesday, March 20, 2018 9:31 AM -
User61956409 posted
Hi amrutha,
If you’d like to update values of TextBox txtigst and txttotal etc without reloading or refreshing page after txtactualpfee_TextChanged is trigger, you can put your TextBox txtigst and txttotal inside another UpdatePanel control, and call .Update() method to update the content of that UpdatePanel control in txtactualpfee_TextChanged event.
<asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional"> <ContentTemplate> <asp:TextBox ID="txttotal" runat="server" Width="300px"></asp:TextBox> </ContentTemplate> </asp:UpdatePanel>
protected void txtactualpfee_TextChanged(object sender, EventArgs e) { txtdifferenc.Text = "{differenc_here}"; UpdatePanel1.Update(); txttotal.Text = "{total_here}"; UpdatePanel2.Update(); }
With Regards,
Fei Han
Sunday, March 25, 2018 6:34 AM -
User-1171043462 posted
Either you set Trigger for both TextBox or simply remove Trigger section.
Saturday, July 14, 2018 12:13 PM