[英]How to enable button after filling text box using c#
As per AntLaC link suggestion I have tried but it is not working in my coding. 根据AntLaC 链接建议,我已经尝试过,但是在我的编码中不起作用。 please help me where i made mistake please let me know.
请在出现错误的地方帮助我,让我知道。 Below is back end code
下面是后端代码
protected void txtCardHolderName1_TextChanged(object sender, EventArgs e)
{
if (txtCardHolderName1.Text.Length > 0)
{
btnNext.Enabled = true;
}
else
{
btnNext.Enabled = false;
}
}
aspx code aspx代码
<asp:UpdatePanel ID="upServiceFee" runat="server">
<ContentTemplate>
<asp:TextBox ID="txtCardHolderName1" runat="server" CssClass="txtbox" Width="220px" ValidationGroup="ServiceFee" MaxLength="100" AutoPostBack="true" AutoCompleteType="Disabled" autocomplete="off" OnTextChanged="txtCardHolderName1_TextChanged"></asp:TextBox>
</ContentTemplate>
</asp:UpdatePanel>
<asp:Button ID="btnNext" runat="server" CssClass="btn btnBlue btnStep" Text="Submit" OnClick="btnSubmit_Click" CausesValidation="true" ValidationGroup="ServiceFee" Enabled="false" />
即使不使用AutoPostBack属性,也可以处理TextChanged事件。
您可以尝试将if语句更改为:
if(textBox != null)
I got My answer with the help of javascript,Thank you so much for helping me. 我在javascript的帮助下得到了我的答案,非常感谢您的帮助。 Just i put below code in postback
只是我在回发中放了下面的代码
string var = ClientScript.GetPostBackEventReference(btnNext, "").ToString();
btnNext.Attributes.Add("onClick", "javascript :if ( Page_ClientValidate() ){this.disabled=true; this.value='Please Wait...';" + var + "};");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.