For example, in the Page_Load code behind I'll use:
ClientScript.RegisterClientScriptBlock(typeof(string), "MyScriptShow", "<script language=javascript>function showIt() { alert('showed it'); }</script>");
If the javascript was in a js file register it in the code behind with:
ClientScript.RegisterClientScriptBlock(typeof(string), "myScripts", "<script language='javascript' src='scripts/myScripts.js'></script>");
In the ASPX page I'll use;
Resource links: link, link
<asp:Button ID="Button1" runat="server" OnClientClick="showIt()" Text="Button" />
Note: Use the ClientScript.RegisterClientScriptBlock or ClientScript.Register_x methods (since Page.Register_x methods are version 1.1)
No comments:
Post a Comment