Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create JavaScript Dynamically on PageLoad 2

Status
Not open for further replies.

stevenk140

Programmer
Nov 20, 2003
34
0
0
CA
How would I create a javascript function dynamically on PageLoad?

 
Code:
in PageLoad:
stirng script = &quot;<script language=javascript>&quot;;
script += &quot;function myFunction(){&quot;;
script += &quot;alert('test');}&quot;;
script += &quot;</script>&quot;;
if(!Page.IsClientScriptBlockRegistered(&quot;myfunction&quot;))
{
  Page.RegisterClientScriptBlock(&quot;myfunction&quot;, script);
}
I think you got the idea. If you need to attach a javascript to an event of a control, then it's done by using Control.Attributes.Add method.
 
LV - nice bit of java here - thanks (I was looking for something like this myself).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top