1

I have a Asp.Net control inside a updatepanel thet is inside a modal popup. I wont to register write javascript code in client from the control code.

these is my code:

Dim output As String = .. javascript code
Page.ClientScript.RegisterClientScriptBlock(Me.GetType(), "frmulaMatrix", output, True)

these is my second thinf but dont work

Page.RegisterClientScriptBlock("SCRIPTNAME", "<script language='javascript'>" + output+"</script>")
0

3 Answers 3

3

You must be trying to do this within a partial post back.

You should do it like this.

  ScriptManager scriptManager = ScriptManager.GetCurrent(Page);
  if (scriptManager != null && scriptManager.IsInAsyncPostBack)
  {
    //if a MS AJAX request, use the Scriptmanager class
    ScriptManager.RegisterStartupScript(Page, Page.GetType(), scriptKey, script, true);
  }
  else
  {
    //if a standard postback, use the standard ClientScript method
    Page.ClientScript.RegisterStartupScript(Page.GetType(), scriptKey, script, true);
  }
Sign up to request clarification or add additional context in comments.

Comments

1

The second method is deprecated. Where in the page life cycle are you calling this code?

Comments

0

try without the script tags. I believe the script manager adds that automatically

script = @"function onBeginRequest myJavascript{
//bla bla
                        }


                this.Page.ClientScript.RegisterStartupScript(this.GetType(), "frmulaMatrix", script, true);

1 Comment

Do you know what have you written? I think somewhere you have not formatted your answer properly

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.