我有一个表单,从其中导航到我的表单,其中有一个用于数量的文本框。之前我是输入数量的。现在,IO 有一个工作流程,这就是其他形式出现的原因。现在,我已经完成了文本框文本更改事件的大量编码。当我做response.redirect
在其他形式中,我也流动数量并将该数量放入该文本框中。现在我不想编写新的代码(函数)来执行相同的操作,因为更新过程也将完成。以下是我尝试执行并调用文本更改事件的代码。我也在使用更新面板。那么,这就是我的活动没有被解雇的原因吗?有什么解决办法吗??
txt_Quantity.TextChanged += new EventHandler(txt_Quantity_TextChanged);
protected void txt_Quantity_TextChanged(object sender, EventArgs e)
{
}
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Panel ID="pnlGrid" runat="server" BorderColor="#339933" Height="400px" BorderStyle="Solid"
BorderWidth="2px" ScrollBars="Auto" Width="100%">
<div style="height: 40px; width: 100%; background-color: #339933;">
<%-- <img alt="imgrid" src="Images/grid_icon_green.png" style="padding-left: 10px;" />--%>
<span style="font-size: 20px; font-family: Calibri; color: White; padding-left: 5px; vertical-align: top">Asset Distribution</span>
</div>
<AjaxToolKit:TabContainer ID="TabContainer1" runat="server" Height="400px">
<AjaxToolKit:TabPanel ID="tab1" runat="server" TabIndex="0" HeaderText="Basic Information">
<ContentTemplate>
<table width="100%">
<tr>
<td class="r1">Last Code:
</td>
<td>
<asp:Label ID="Lbl_AssetDistriCode" runat="server"></asp:Label>
</td>
<td width="10%" class="r1">Item Code:
</td>
<td width="23%">
<asp:TextBox ID="txt_ItemCode" runat="server" Height="95%" Width="150px" CssClass="txtbxcomp" AutoPostBack="true" OnTextChanged="txt_ItemCode_TextChanged"></asp:TextBox>
<%-- <span style="color: Red;">*</span>--%>
<AjaxToolKit:AutoCompleteExtender ID="AutoCompleteExtender4" runat="server" ServiceMethod="getitem"
ServicePath="WebService.asmx" TargetControlID="txt_ItemCode" CompletionInterval="500"
MinimumPrefixLength="1" EnableCaching="true" CompletionSetCount="5">
</AjaxToolKit:AutoCompleteExtender>
</td>
<td width="10%"></td>
<td width="24%"></td>
</tr>
<tr>
<td class="r1" width="10%">Item Group:
</td>
<td width="23%">
<asp:DropDownList ID="ddl_Item_Grp" runat="server" Height="95%" Width="150px" CssClass="drpComp" AutoPostBack="True"
OnSelectedIndexChanged="ddl_Item_Grp_SelectedIndexChanged">
</asp:DropDownList>
<%-- <span style="color: Red;">*</span>--%>
</td>
<td class="r1" width="10%">Item Type:
</td>
<td width="23%">
<asp:DropDownList ID="ddl_Item_typ" runat="server" Height="95%" Width="150px" CssClass="drpComp" AutoPostBack="True"
OnSelectedIndexChanged="ddl_Item_typ_SelectedIndexChanged">
</asp:DropDownList>
<%--<span style="color: Red;">*</span>--%>
</td>
<td class="r1" width="14%">Item Catagory:
</td>
<td width="20%">
<asp:DropDownList ID="ddl_Item_cat" runat="server" Height="95%" Width="150px" CssClass="drpComp"></asp:DropDownList>
<%--<span style="color: Red;">*</span>--%>
</td>
</tr>
<tr>
<td class="r1" width="10%">City:
</td>
<td width="23%">
<asp:DropDownList ID="ddl_city" runat="server" Height="95%" Width="150px" CssClass="drpComp" AutoPostBack="True"
OnSelectedIndexChanged="ddl_city_SelectedIndexChanged">
</asp:DropDownList>
<%--<span style="color: Red;">*</span>--%>
</td>
<td class="r1" width="10%">Location:
</td>
<td width="24%">
<asp:DropDownList ID="ddl_Loc" runat="server" Height="95%" Width="150px" CssClass="drp"
>
</asp:DropDownList>
<%--<span style="color: Red;">*</span>--%>
</td>
<td class="r1" width="10%">Branch:
</td>
<td width="23%">
<asp:DropDownList ID="ddl_Branch" runat="server" Height="95%" Width="150px" CssClass="drpComp" AutoPostBack="True"
OnSelectedIndexChanged="ddl_Branch_SelectedIndexChanged">
</asp:DropDownList>
<%--<span style="color: Red;">*</span>--%>
</td>
</tr>
<tr>
<td class="r1" width="10%">Department:
</td>
<td width="24%">
<asp:DropDownList ID="ddl_Dept" runat="server" Height="95%" Width="150px" CssClass="txtbx" AutoPostBack="True"
OnSelectedIndexChanged="ddl_Dept_SelectedIndexChanged">
</asp:DropDownList>
<%--<span style="color: Red;">*</span>--%>
</td>
<td class="r1" width="10%">User:
</td>
<td width="23%">
<asp:DropDownList ID="ddl_User" runat="server" Height="95%" width="150px" CssClass="txtbx" AutoPostBack="True"></asp:DropDownList>
<%--<span style="color: Red;">*</span>--%>
</td>
<%--<td class="r1" width="15%">Asset Code:
</td>
<td width="19%">
<asp:DropDownList ID="ddl_Asset_code" runat="server" Height="95%" CssClass="txtbx" AutoPostBack="True"></asp:DropDownList>
<span style="color: Red;">*</span>
</td>--%>
<td class="r1" width="10%">Quantity:
</td>
<td width="23%">
<asp:TextBox ID="txt_Quantity" runat="server" Height="95%" Width="150px" CssClass="txtbxcomp" AutoPostBack="true" OnTextChanged="txt_Quantity_TextChanged"></asp:TextBox>
<cc1:FilteredTextBoxExtender ID="FilteredTextBoxExtender3" runat="server" TargetControlID="txt_Quantity"
ValidChars="0123456789." Enabled="True">
</cc1:FilteredTextBoxExtender>
<%-- <span style="color: Red;">*</span>--%>
</td>
<td width="10%"></td>
<td width="24%"></td>
</tr>
<%--<tr>
<td width="15%" class="r1">Mac ID:
</td>
<td width="18%">
<asp:TextBox ID="txt_MacId" runat="server" Height="95%" CssClass="txtbx"></asp:TextBox>
<span style="color: Red;">*</span>
</td>
<td width="15%"></td>
<td width="18%"></td>
<td width="15%"></td>
<td width="19%"></td>
</tr>--%>
</table>
</ContentTemplate>
</AjaxToolKit:TabPanel>
</ContentTemplate>
<Triggers>
<asp:PostBackTrigger ControlID="btnSave" />
<asp:PostBackTrigger ControlID="btnUpdate" />
<asp:PostBackTrigger ControlID="btndelete" />
<asp:PostBackTrigger ControlID="btnClear" />
</Triggers>
</asp:UpdatePanel>
提前致谢。
The OnTextChanged
仅当您在文本框中进行更改并按 Tab 键退出该字段时才会发生。或者你可以说AutoPostBack
当文本框失去焦点时,文本框上的内容将触发回发。
the OnTextChanged
当您在文本框中键入内容时,不会触发事件。OnTextChanged
是服务器端事件,仅在页面回发时触发。在页面上的文本框中键入内容不会将页面发回,因此只有在通过不同方式发布页面后才会触发此事件,例如:单击按钮等。因此,请确保在更改文本后,您将移出的文本框。
使用更新面板很好,一旦发生回发,将调用 TextChanged 事件来执行页面生命周期的适当阶段。
另外,尝试保留文本框代码相同,但删除 UpdatePanel。换句话说,完全取消 AJAX,看看您的事件是否在常规回发期间触发(以及您是否在预期时收到回发)。这肯定有助于缩小问题范围。
如果您希望每次进行 KeyStroke 时触发此事件(当您输入时),这将有帮助:如何使 ASP.NET TextBox 在 AJAX UpdatePanel 中触发 onTextChanged 事件? https://stackoverflow.com/questions/1009086/how-to-make-an-asp-net-textbox-fire-its-ontextchanged-event-fire-in-an-ajax-upd
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)