External JS reference

Saturday, April 18, 2009

usually use the following code to reference an external JavaScript file and it works fine with ASP. NET 1.1, hope it works fine with you.

Page.RegisterClientScriptBlock(string key, string script);

This peace of code register a client side JavaScript block with "Script Key" (If this is already registered then previous f.js file will be replaced) and script -- external file that is referenced.

if(Page.IsClientScriptBlockRegistered(string key))

this peace of code checks if script block is registered or not.

after that JavaScript fucntion can be called from the C# code, some what like this.

button1.Attributes.Add("onClick", "javascript:return function name();");

0 comments

Post a Comment

LinkWithin

Blog Widget by LinkWithin

Recommended Books