For example I need to change the body onload event in html.
In the asp.net file, we simply cast our master page as its class name.
in master page aspx we add the code below.
<body onload="<%=myloadstr %>" >
in master page cs code we add the code below.
we declare it as public to access the variable.
public string myloadstr = "";
And add the code below in your asp.net cs source file.
((myMasterPage)this.Master).myloadstr = "here some javascript for load";
myMasterPage is the name of my masterpage class. We cast our asp.net page its masterpage, with "this.Master".