-1

window.execscript("mycode","javascript") is not working when tried to execute,also not giving any exception at that point.Any suggestion is welcome.

Thanks in Advance

1
  • 4
    Welcome to Stack Overflow! Unfortunately, your question does not contain much detail and it will be hard to answer unless you can provide some more context. Commented Jun 22, 2010 at 7:09

2 Answers 2

1

If you are interested in running JavaScript on the server, then see this related question Execute javascript on IIS server

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

Comments

0

You know we can't execute javascript from code behind at server side. What we can do is to register a java script and make it run after the page is rendered at client side. Here is an example:

//Page_Load method in Default.aspx.cs, notepad code
string js = "<script type='text/javascript'> alert('hello world!'); </script>";
ClientScript.RegisterStartupScript(this.GetType(),"helloworld",js);

Here I use a string directly, usually you can generate a complex javascript with StringBuilder. RegisterStartupScript will add the js to the page and execute it when the script is loaded.

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.