Ali_dotNet
Ali_dotNet

Reputation: 3279

javascript function not called on pageload after postback

I use following function in my ASP.NET page_load function to load a javascript function in my startup (I use masterpage):

((System.Web.UI.HtmlControls.HtmlGenericControl)Master.FindControl("Body")).Attributes["onload"] = "initialize()";

it seems that my javascript function is not called after postback, what is going wrong?

Upvotes: 0

Views: 679

Answers (1)

codingbiz
codingbiz

Reputation: 26386

Why not use ClientScript.RegisterClientScriptBlock() instead

string myscript = "<script type=\"text/javascript\">"+
        "divTimer();" +
        "initialize();" +
    "</script>";

ClientScript.RegisterClientScriptBlock( this.GetType(), "myscript", myscript);

Upvotes: 2

Related Questions