1

I have one aspx page where I need to validate some fields, I made this validation on C# code, but there wasn't working.

So I tried put a simple code only to discover what was the problem, so I realized that didn't matter the code, if I run a ScriptManager.RegisterStartupScript or a ScriptManager.RegisterClientScriptBlock, my C# code doesn't work.

Here is an example:

protected void btnBuscar_Click(object sender, EventArgs e){
   this.lblValidarEmpresa.Visible = false;
   ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "script", "AplicarMascara();", false);
}

The function AplicarMascara() applies a data mask on a text field.

Do you know how solve this problem? Or any other way to apply this mask without use ScriptManager?

Thanks.

1
  • I forgot to say that I'm using an UpdatePanel on controller. Commented Nov 18, 2014 at 20:39

2 Answers 2

1

On the first sight, try to change last parameter (addScriptTags) to true.

Sign up to request clarification or add additional context in comments.

Comments

0

It looks like you're trying to execute javascript code when the button is pushed and things are getting complicated with the use of the updatepanel. Have you considered triggering "AplicarMascara" using the onclientclick property of btnBuscar? You didn't post your code for the button definition but here's a sample of what it should look like:

<asp:Button id="btnBuscar" OnClientClick="AplicarMascara" runat="server" />

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.