1. <i id='mEeb8'><tr id='mEeb8'><dt id='mEeb8'><q id='mEeb8'><span id='mEeb8'><b id='mEeb8'><form id='mEeb8'><ins id='mEeb8'></ins><ul id='mEeb8'></ul><sub id='mEeb8'></sub></form><legend id='mEeb8'></legend><bdo id='mEeb8'><pre id='mEeb8'><center id='mEeb8'></center></pre></bdo></b><th id='mEeb8'></th></span></q></dt></tr></i><div id='mEeb8'><tfoot id='mEeb8'></tfoot><dl id='mEeb8'><fieldset id='mEeb8'></fieldset></dl></div>

        • <bdo id='mEeb8'></bdo><ul id='mEeb8'></ul>
        <tfoot id='mEeb8'></tfoot>
      1. <legend id='mEeb8'><style id='mEeb8'><dir id='mEeb8'><q id='mEeb8'></q></dir></style></legend>
      2. <small id='mEeb8'></small><noframes id='mEeb8'>

        通过以编程方式更改文本框值来调用 Javascript o

        时间:2023-08-07
          <i id='Kd3JL'><tr id='Kd3JL'><dt id='Kd3JL'><q id='Kd3JL'><span id='Kd3JL'><b id='Kd3JL'><form id='Kd3JL'><ins id='Kd3JL'></ins><ul id='Kd3JL'></ul><sub id='Kd3JL'></sub></form><legend id='Kd3JL'></legend><bdo id='Kd3JL'><pre id='Kd3JL'><center id='Kd3JL'></center></pre></bdo></b><th id='Kd3JL'></th></span></q></dt></tr></i><div id='Kd3JL'><tfoot id='Kd3JL'></tfoot><dl id='Kd3JL'><fieldset id='Kd3JL'></fieldset></dl></div>

          1. <legend id='Kd3JL'><style id='Kd3JL'><dir id='Kd3JL'><q id='Kd3JL'></q></dir></style></legend>
              <tbody id='Kd3JL'></tbody>
          2. <small id='Kd3JL'></small><noframes id='Kd3JL'>

                <tfoot id='Kd3JL'></tfoot>
                • <bdo id='Kd3JL'></bdo><ul id='Kd3JL'></ul>
                  本文介绍了通过以编程方式更改文本框值来调用 Javascript onchange 事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我面临的问题是:

                  • 我在日历控件旁边有一个日期范围的文本框.
                  • 当用户从日历中选择一个日期时,它会将该日期填充到文本框中
                  • 发生这种情况时,我想触发一个 javascript 函数,但是,'onchange' 事件似乎没有发生.

                  理想情况下,我希望能够将事件作为属性添加到文本框,例如:

                  I'd ideally like to be able to add the event as an attribute to the textbox, something like:

                  txtCreateDate.Attributes.Add("onchange", string.Format("JSfunction({0},'{1}');", arg1, arg2));
                  

                  更多信息:在 c# 中将日期输入到文本框中.日历控件在页面上有一个事件处理程序.选择日期后,事件处理程序将日期放入文本框中.此时我已尝试将焦点设置到文本框,然后在文本框上放置一个 onBlur 属性,但文本框似乎从未获得焦点.

                  more info: The date is entered into the textbox in c#. The calendar control has an eventhandler on the page. When a date is selected, the eventhandler puts the date into the textbox. I have tried setting the focus to the textbox at this point, then putting an onBlur attribute on the textbox, but the textbox never seems to get focus.

                  我想此时我可以直接调用 javascript 函数来执行 ClientScript.RegisterClientScriptBlock 或类似的操作,但这似乎很草率,而且永远不会像我想要的那样工作.

                  I suppose I could directly call the javascript function at this point doing ClientScript.RegisterClientScriptBlock or something like that, but that seems sloppy and never works like I want it to.

                  推荐答案

                  您误解了 onchange 事件在应用于 textarea 时的作用.直到失去焦点或您按下回车键,它才会触发.为什么不从填充文本区域的选择上的 onchange 触发函数?

                  You're misinterpreting what the onchange event does when applied to a textarea. It won't fire until it loses focus or you hit enter. Why not fire the function from an onchange on the select that fills in the text area?

                  在此处查看有关 onchange 事件的更多信息:w3schools

                  Check out here for more on the onchange event: w3schools

                  这篇关于通过以编程方式更改文本框值来调用 Javascript onchange 事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:更改文本框 HTML/CSS 中一个字符的颜色 下一篇:将文本字段限制为仅数字的最佳方法?

                  相关文章

                  最新文章

                • <small id='1uKaS'></small><noframes id='1uKaS'>

                    <legend id='1uKaS'><style id='1uKaS'><dir id='1uKaS'><q id='1uKaS'></q></dir></style></legend>

                    <tfoot id='1uKaS'></tfoot>

                      <i id='1uKaS'><tr id='1uKaS'><dt id='1uKaS'><q id='1uKaS'><span id='1uKaS'><b id='1uKaS'><form id='1uKaS'><ins id='1uKaS'></ins><ul id='1uKaS'></ul><sub id='1uKaS'></sub></form><legend id='1uKaS'></legend><bdo id='1uKaS'><pre id='1uKaS'><center id='1uKaS'></center></pre></bdo></b><th id='1uKaS'></th></span></q></dt></tr></i><div id='1uKaS'><tfoot id='1uKaS'></tfoot><dl id='1uKaS'><fieldset id='1uKaS'></fieldset></dl></div>
                      • <bdo id='1uKaS'></bdo><ul id='1uKaS'></ul>