JQuery绑定文本框autopostback [英] JQuery bound textbox autopostback

查看:62
本文介绍了JQuery绑定文本框autopostback的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我希望你们能帮帮我。



我设计的使用webform的小型预订应用程序。当表单上的信息发生变化时,它总是回发以自动更新gridview结果或隐藏gridview。除了绑定到JQuery日期选择器的两个文本框之外,Autopostaback工作正常。我对文本框和C#onTextChanged事件处理程序都有autopostback = true。但是绑定到datepicker的两个文本框在更改日期时永远不会回发。我一直在研究三天,最后决定向你们寻求帮助。



我们非常感谢任何建议。



提前致谢



文本框代码1.它的事件处理程序只说隐藏gridview(gridview1.visible = false; gridview1.databind() ;)

 <   td  < span class =code-attribute>   class   =  style10 >  
< asp:TextBox ID = StartDate class = dropdownArrow1 runat = server

宽度 = 200px 高度 = 20px BorderColor = #cccccc align = left BackColor = #ffffbec
< span class =code-attribute>
BorderWidth = 1px BorderStyle = solid AutoPostBack = true OnTextChanged = StartDate_TextChanged > < / asp:TextBox >
< asp:日历 ID = CalendarStartDate runat = server 可见 = 错误 > < ; / asp:日历 >
< asp:RequiredFieldValidator ID = Requ iredStartDate runat = server ControlToValidate = StartDate ErrorMessage = * ForeColor = 红色 > < / asp:RequiredFieldValidator >
< / td >





我有另一个类似的文本框代码2



谢谢

解决方案

啊,我看到了这个问题。文本框上的AutoPostBack通常在焦点丢失(或点击输入)时发生。当jQuery datepicker为你更新它时不会发生这种情况。



你可以做的是用jquery将所有类型的更改绑定到回发:

 


function (){ // on document.ready
var textbox =

input [id


Hi all,

I am hoping you guys can help me.

I have designed a small booking application using webform. When information change on the form, it always postback to automatically update the gridview result or hide the gridview. Autopostaback works fine in all but the two textboxes that are bound to a JQuery datepicker. I have autopostback = true for the textboxes and also C# onTextChanged event handler. But the two textboxes bound to datepicker never postback when the date is changed. I been researching for three days now and finally decided to get help from you guys.

Any suggestion is greatly appreciated.

Thanks in advance

Code for textbox 1. The event handler for it only say hide gridview (gridview1.visible = false; gridview1.databind();)

<td class="style10">
<asp:TextBox ID="StartDate" class="dropdownArrow1"  runat="server"

Width="200px" Height="20px" BorderColor="#cccccc" align="left" BackColor="#fffbec"

BorderWidth="1px" BorderStyle="solid" AutoPostBack="true" OnTextChanged="StartDate_TextChanged" ></asp:TextBox>
<asp:Calendar ID="CalendarStartDate" runat="server" Visible="False" ></asp:Calendar>
<asp:RequiredFieldValidator ID="RequiredStartDate" runat="server" ControlToValidate="StartDate" ErrorMessage="*" ForeColor="Red"></asp:RequiredFieldValidator>
      </td>



I have another similar code for textbox 2

Thanks

解决方案

Ah, I see the issue. AutoPostBack on textboxes usually occurs when focus is lost (or enter is clicked). This doesn't happen when the jQuery datepicker updates it for you.

What you can do is bind all types of change to a postback with jquery:


(function(){ //On document.ready var textbox =


("input[id


这篇关于JQuery绑定文本框autopostback的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆