Add the script in webpart.cs file.
private const string EmbeddedScriptFormat = "<script language=\"javascript\">$(document).ready( function(){alert('hi');});</script>";
//TESTWEBPART() is the default constructor name of the webpart class
public TESTWEBPART()
{
this.PreRender += new EventHandler(WebPart_ClientScript_PreRender);
}
private void WebPart_ClientScript_PreRender(object sender, System.EventArgs e)
{
if (!Page.IsClientScriptBlockRegistered(ByeByeIncludeScriptKey))
Page.RegisterClientScriptBlock(ByeByeIncludeScriptKey,
EmbeddedScriptFormat);
}
No comments:
Post a Comment