问题描述
在我的项目,我使用的UpdatePanel里面的文本框来显示收据号码是不是已经在数据库表存在。
不过,虽然打字文本框TextChanged事件不会开火。我的逻辑是在打字时,显示可用收据。如果没有那么显示的用户可以插入收据号码。
< ASP:的UpdatePanel ID =updAvailableReceipt=服务器>
<&的ContentTemplate GT;
< ASP:文本框ID =txtReceiptNo=服务器级=textBoxStyle的AutoPostBack =真OnTextChanged =txtReceiptNo_TextChanged>< / ASP:文本框>
< ASP:GridView控件ID =grdShowAvailableReceipt=服务器EnableTheming =真ShowHeader =FALSE>
< / ASP:GridView的> < /&的ContentTemplate GT;
<&触发器GT;
< ASP:AsyncPostBackTrigger控件ID =txtReceiptNo事件名称=框TextChanged/>
< /触发器>
< / ASP:的UpdatePanel>
保护无效txtReceiptNo_TextChanged(对象发件人,EventArgs的发送)
{
参数= ParameterClass.IniliazeParameter(1);
诠释计数= 0;
ParameterClass.AddParameter(参考参数,@ReceiptNumber,txtReceiptNo.Text,引用计数);
grdShowAvailableReceipt.DataSource =新bAuctionPayment()获取(RecordFetchMode.FethcAvailableReceipt,参数)。
grdShowAvailableReceipt.DataBind();}
您可以创建一个在服务器端的程序,并与JavaScript执行它。
下面使用的逻辑很简单,创建一个过程,添加一个按钮,并设置能见度虚假或显示:使用CSS没有。
则该过程开火按钮的点击,然后单击事件正在从JavaScript的触发。
随意问,如果你遇到任何问题。
VB code
公用Sub FetchRecord() 你的code这里.. 结束小组保护小组btnView_Click(BYVAL发件人为对象,BYVAL E上System.EventArgs)把手btnView.Click
FetchRecord()
结束小组
的JavaScript
<脚本类型=文/ JavaScript的>
功能过滤器(){
的document.getElementById('<%= btnView.ClientID%GT;')。点击()
}
< / SCRIPT>
In my project i am using Textbox inside updatepanel to display the Receipt number which is not already exist in db table. But the textchanged event on the textbox is not firing while typing. My Logic is to display available receipt while typing. If nothing displayed then user can insert that receipt number.
<asp:UpdatePanel ID="updAvailableReceipt" runat="server">
<ContentTemplate>
<asp:TextBox ID="txtReceiptNo" runat="server" class="textBoxStyle" AutoPostBack="true" OnTextChanged="txtReceiptNo_TextChanged"></asp:TextBox>
<asp:GridView ID="grdShowAvailableReceipt" runat="server" EnableTheming="True" ShowHeader="False">
</asp:GridView>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="txtReceiptNo" EventName="TextChanged" />
</Triggers>
</asp:UpdatePanel>
protected void txtReceiptNo_TextChanged(object sender, EventArgs e)
{
param = ParameterClass.IniliazeParameter(1);
int count=0;
ParameterClass.AddParameter(ref param, "@ReceiptNumber", txtReceiptNo.Text, ref count);
grdShowAvailableReceipt.DataSource = new bAuctionPayment().Fetch(RecordFetchMode.FethcAvailableReceipt, param);
grdShowAvailableReceipt.DataBind();
}
You can create a procedure in serverside and execute it with javascript.The logic used below is simple, create a procedure, add a button and set visibility to false or display: none with css.The procedure is then fired on click of the button, and the click event is being triggered from the javascript.Feel free to ask if you encounter any problem
vb code
Public Sub FetchRecord()
'Your Code Here..
End Sub
Protected Sub btnView_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnView.Click
FetchRecord()
End Sub
Javascript
<script type="text/javascript">
function Filter() {
document.getElementById('<%= btnView.ClientID %>').click()
}
</script>
这篇关于如何激发文本框TextChanged事件,而在文本框中输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!