1

I have this code on the OnClick event of a Button:

if (true) {
  ClientScript.RegisterStartupScript(UpdatePanel1.GetType(), "", "show_modal('true');", true);
} else {
  ClientScript.RegisterStartupScript(UpdatePanel1.GetType(), "", "show_modal();", true);
}

And I define the Button as a trigger for an UpdatePanel:

<Triggers>
  <asp:AsyncPostBackTrigger ControlID="btnEdit" EventName="Click" />
</Triggers>

The function show_modal is located into a .js file which is included into the ASP page.

How can I make this script works?

2

1 Answer 1

2

Do not use ClientScript.RegisterStartupScript. Use ScriptManager1.RegisterStartupScript instead. Where "ScriptManager1" is the name of your ScriptManager control.

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

2 Comments

It's not ScriptManager1, it's just ScriptManager. RegisterStartupScript is a shared function (ie: a class method, not an instance one) of ScriptManager class.
What about when you need to write a generic method that would run on any page? codecorner.galanter.net/2011/03/03/…

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.