Reusable Page_PreRender function in asp.net <p>I have a function which sets my linkbutton as the default button for a panel.</p> <pre><code>protected void Page_PreRender(object sender, EventArgs e) { string addClickFunctionScript = @"function addClickFunction(id) { var b = document.getElementById(id); if (b &amp;&amp; typeof(b.click) == 'undefined') b.click = function() { var result = true; if (b.onclick) result = b.onclick(); if (typeof(result) == 'undefined' || result) eval(b.getAttribute('href')); } };"; string clickScript = String.Format("addClickFunction('{0}');", lbHello.ClientID); Page.ClientScript.RegisterStartupScript(this.GetType(), "addClickFunctionScript", addClickFunctionScript, true); Page.ClientScript.RegisterStartupScript(this.GetType(), "click_" + lbHello.ClientID, clickScript, true); } </code></pre> <p>This works fine. How to make this reusable to all my pages of my application. One page can have multiple linkbuttons and multiple panels.... Any suggestion...</p>