[RESOLVED]How to Clear the text in textbox while using ValidatorCalloutExtender?

Hi,

      I am using  ‘ValidatorCalloutExtender’ for textbox, after clicking the cancel button in the Extender Box i want to clear the text in the  textbox .Any one suggest me the solution..

try to clear like this

textbo1.Text ="";

validator.Text="";

validator.EnableClientScript = false;

Thank you  for the reply,

       can you please explain me clearly, i mean where i have to use that lines of code.

Text.Trim();

txtname.Text="";

Txtname.Text =null;

in your code behind..

if you have button u can write that code in button Click Event

Here is my Aspx page code :

<asp:TextBox ID="txtImageId" runat="server" Width="100px"></asp:TextBox>
<asp:RegularExpressionValidator ID="ImageID" runat="server" ErrorMessage="Enter only digits & length greater than 5 "
                        ControlToValidate="txtImageId" Display="None" ValidationExpression="d{0,5}"></asp:RegularExpressionValidator>
<asp:ValidatorCalloutExtender ID="ValidatorCalloutExtender1" runat="server" TargetControlID="ImageID"
                        CssClass="CustomValidatorCalloutStyle" PopupPosition="TopLeft">
                    </asp:ValidatorCalloutExtender>


If validation occurs in the textbox then  this ExtenderBox will come ,by clicking cancel button the text in textbox has to clear.

can you post your complete aspx code? including your buttons?

here it is in aspx page

<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />
<asp:TextBox ID="txtImageId" runat="server" Width="100px"></asp:TextBox>
<asp:RegularExpressionValidator ID="ImageID" runat="server" ErrorMessage="Enter only digits & length greater than 5 "
ControlToValidate="txtImageId" Display="None" ValidationExpression="d{0,5}"></asp:RegularExpressionValidator><asp:ValidatorCalloutExtender ID="ValidatorCalloutExtender1" runat="server" TargetControlID="ImageID"
CssClass="CustomValidatorCalloutStyle" PopupPosition="TopLeft">
</asp:ValidatorCalloutExtender>

in cs page

protected void Button1_Click(object sender, EventArgs e)
{
txtImageId.Text = "";

}

I am generating ValidatorCalloutExtender on tab key press, i dont want to perform that action on button click

Leave a Reply