I have a javascript method which I have to call from the aspx page at the time of page load.
+4
A:
Javascript methods are client-side methods, so you can not call them in your server side code.
But if you're looking for a way to call your method at the page load put your method call into script tag and write it in your aspx page :
<body>
<script language="javascript">
myMethod();
</script>
</body>
Or you can register your scripts from code-behind like that :
protected void Page_Load(object sender, EventArgs e)
{
string script = "myMethod();";
if (!this.Page.ClientScript.IsClientScriptBlockRegistered("myPostBackScript"))
{
this.Page.ClientScript.RegisterClientScriptBlock(typeof(MyPage),
"myPostBackScript", script, true);
}
}
Canavar
2009-05-02 11:05:33
the problem is that i am using updatepanel
saurabh
2009-05-02 11:57:39
I think you want to call this js function everytime the page partial postbacks using UpdatePanel?
Daud
2009-05-02 12:18:07
ok i got the solution thanx for advice......
saurabh
2009-05-02 12:33:06