"If at first you don't succeed; call it version 1.0" :-Unknown

Pages

Saturday, December 22, 2012

Call Client Side JavaScript function() from Server Side

Call Client Side JavaScript function() from Server Side

You can find million of forums with same question and answers.Last day i cn a post in codeproject by P.Salini. Given a well documented solution for it.


Page.RegisterStartupScript("page"
"<script language="'javascript'">dTime()</script>");

in place of page.RegisterStartupScript you can also use ClientScript.RegisterClientScriptBlock

if you are using update panel in your aspx page then use

ScriptManager.RegisterClientScriptBlock

for scriptmanager

and also


string script = "<script language='javascript'>MyFunction();</script>";
ScriptManager.RegisterStartupScript(Page, Page.GetType(), Guid.NewGuid().ToString(), script, false);

Thank you Salini ,not just for sharing the answer also for the documentation.
Url: http://www.codeproject.com/Questions/270176/Call-Client-Side-from-Server-Side

If u had any trouble just ask, Happy to help u :) 
Stay Tune... 
Have a nice day... 'N happy Coding :)

No comments: