在asp.net中自动调用文本框textchange事件

2024-05-09

我有一个表单,从其中导航到我的表单,其中有一个用于数量的文本框。之前我是输入数量的。现在,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(使用前将#替换为@)

在asp.net中自动调用文本框textchange事件 的相关文章

随机推荐

  • 为什么 Internet Explorer 不喜欢这个 jQuery?

    在调试一些在 IE 中不起作用的 jQuery 时 我发现了以下错误消息 var item item itemArray itemIndex find a text trim Object doesn t support this prop
  • AngularJS - 转到上一个/下一个模式

    我正在使用 Angular 构建一个应用程序 其中有一个项目列表 使用 ng repeat 通过单击每个项目 我可以打开一个模式以查看更详细的描述 现在 为了切换到另一个模式 我必须关闭前一个模式 转到列表 然后单击打开另一个模式 我想在单
  • Rails 资产 - 保留许可证注释

    如何防止 Uglifier 删除某些文件中的某些注释 我希望缩小和压缩代码 但我也希望许可注释保持不变 来自 uglifyJS 的文档 nc or no copyright 默认情况下 uglifyjs 将在生成的代码中保留初始评论标记 假
  • 如何制作 HTML/CSS/JS 变色背景(如 Kahoot.it 那样)

    如何使用 html 和 css 以及可能的 javascript 制作类似于 waht 的颜色变化 褪色背景https kahoot it https kahoot it has 你应该学会检查和获取 keyframes bgcolor 0
  • 如何修改 GNUPlot 创建的饼图

    Input 我有一个myfile csv包含以下信息的文件 Shift Percentage Day Shift 39 94 Night Shift 60 06 GNU绘图处理 The myfile csv文件被送入pie chart ge
  • Android 可检查子菜单选项

    所以我有一个用于选项菜单项的子菜单 我想要一个可检查条目的列表 用户可以根据需要选择 取消选择多个条目 我无法解决的唯一问题是如何防止单击其中一个复选框时关闭选项菜单 我看到 PerformShortcut 有一个 FLAG PERFORM
  • 无法在 mysql 表中的值中使用破折号(-)[重复]

    这个问题在这里已经有答案了 我一直在尝试从 python 将数据插入 MYSQL 表 我的sql表中的字段是id token start time end time和no of trans 我想存储使用生成的令牌uuid4在令牌栏中 但由于
  • MVC Owin Identity 2 CheckPasswordAsync() 将不会执行

    我有两个问题似乎彼此相关 并且 stackoverflow 中的其他重复项都不能回答我的问题 First当 的时候PasswordSignInAsync方法执行它永远不会停止或抛出任何异常它只是继续执行 var result await S
  • iPhone模拟器的屏幕截图应用程序[关闭]

    Closed 这个问题正在寻求书籍 工具 软件库等的推荐 不满足堆栈溢出指南 help closed questions 目前不接受答案 我想知道有没有什么好的推荐iPhone模拟器截图的应用程序 我尝试过 iPhone 屏幕截图裁剪器等应
  • Windows 服务器上的 .htaccess 文件

    我进行了研究 发现我的 htaccess 文件无法在我的新 Windows 服务器上运行 我发现我应该使用 web config 我尝试了一下 但没有任何效果 然后我发现我可以使用 htaccess 文件 但我必须将其命名为其他名称 例如
  • 使用 with 的热切加载模型,但给它起了另一个名字 - Laravel 5.2

    是否可以使用 with 方法来使用预加载 但给它另一个名称 就像是 gt with documents as product documents documents as categories 我有一个可以是产品或类别的文档表 急切加载可以
  • Python 小数.InvalidOperation 错误

    当我运行这样的东西时 我总是收到此错误 from decimal import getcontext prec 30 b 2 3 Decimal b Error Traceback most recent call last File Te
  • 将打开关闭的 Google Chrome 浏览器添加到 Selenium linkedin_scraper 代码中

    我正在尝试抓取一些知名人士的 LinkedIn 个人资料 该代码获取一堆 LinkedIn 个人资料 URL 然后使用Selenium and scrape linkedin收集信息并将其作为 json 文件保存到文件夹中 我遇到的问题是
  • 概念数据建模:RDF 是正确的工具吗?其他解决方案?

    我正在规划一个系统 该系统结合了各种数据源 并允许用户对这些数据源进行简单的查询 系统的一部分需要充当抽象层 了解所有连接的数据源 用户不应该 需要 了解底层数据 提供者 数据提供者可以是任何东西 关系 DBMS 错误跟踪系统 气象站 它们
  • 弹性搜索文档计数

    我正在运行 2 2 版本的 Elastic 搜索 我已经创建了索引并加载了示例文档 我发现其中有些问题 当我给予 GET index type count 我得到了正确的答案 count 9998 shards total 5 succes
  • shell 脚本:错误的解释器:使用 pwd 时没有这样的文件或目录

    我想用 for 循环遍历目录中的文件 但这出现了 echo bad interpreter No such file or directory code bin bash count 0 dir pwd echo dir FILES ls
  • Strimzi 运算符 Kafka 集群 ACL 未启用类型:简单

    我们知道要启用Kafka ACL属性authorizer class name kafka security auth SimpleAclAuthorizer要添加到server properties但是如果 Kafka 集群由 Strim
  • 如何计算位图的平均 RGB 颜色值

    在我的 C 3 5 应用程序中 我需要获取位图的红色 绿色和蓝色通道的平均颜色值 最好不使用外部库 这可以做到吗 如果是这样 怎么办 提前致谢 尝试让事情变得更精确 位图中的每个像素都有一定的 RGB 颜色值 我想获取图像中所有像素的平均
  • 在 kubernetes 上安装 PySpark 软件包时出现 Spark-Submit:ivy-cache 文件未找到错误

    我一整天都在与它斗争 我能够安装并使用带有 Spark shell 或连接的 Jupiter 笔记本的包 graphframes 但我想使用 Spark Submit 将其移动到基于 kubernetes 的 Spark 环境 我的火花版
  • 在asp.net中自动调用文本框textchange事件

    我有一个表单 从其中导航到我的表单 其中有一个用于数量的文本框 之前我是输入数量的 现在 IO 有一个工作流程 这就是其他形式出现的原因 现在 我已经完成了文本框文本更改事件的大量编码 当我做response redirect在其他形式中