Wednesday, November 05, 2008

Calling Javascript from C#, Calling Javascript from Codebehind ASP.NET

Calling Javascript from C#, Calling Javascript from Codebehind

We can use the following two methods to access Java Script from C#
Page.ClientScript.RegisterStartupScript() Method
Page.ClientScript.RegisterClientScriptBlock() Method

Eg:

string script = "< LANGUAGE='JavaScript'> ";
script += "ApptConfirm()";
script += "</SCRIPT>";

// We use RegisterStartupScript, so that this script is executed after all form elements are rendered.
Page.RegisterStartupScript("ClientScript", script);

No comments: