在我的项目中,我使用updatepanel内的Textbox来显示db表中尚不存在的Receipt号。 但是键入时文本框上的textchanged事件不会触发。我的逻辑是在打字时显示可用的收据。如果没有显示任何内容,则用户可以插入该收据编号。
<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();
}
答案 0 :(得分:0)
使用它,它工作正常
JAVASCRIPT
function ChangeText() {
var t1 = document.getElementById('<%= txtArticleTitle.ClientID %>');
var t2 = document.getElementById('<%= txtPageName.ClientID %>');
t2.value = t1.value;
}
ASP.NET SOURCE
Article Title:
<asp:TextBox ID="txtArticleTitle" runat="server" onkeyup="ChangeText()" Width="600px"></asp:TextBox>
<br />
Page Name:
<asp:TextBox ID="txtPageName" runat="server" Width="600px"></asp:TextBox>
答案 1 :(得分:0)
两个音符。
当文本框失去焦点时,Textchanged会触发。您可以使用keyd自己或按键事件。
建议不要在每次用户按键时调用服务器。考虑使用超时,以便仅在用户完成输入时调用服务器(我认为标准为350毫秒)或从服务器预加载列表并过滤客户端。
P.S。
不要使用ASP.Net ajax ......只是说。
答案 2 :(得分:0)
您可以在服务器端创建一个过程并使用javascript执行它。 下面使用的逻辑很简单,创建一个过程,添加一个按钮并将可见性设置为false或display:none with css。 然后单击该按钮触发该过程,并从javascript触发click事件。 如果您遇到任何问题,请随时询问
vb代码
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>