How to use Javascript using Server-side scripting
Hi.
This article is interesting for those who
loves to use javascript, but with little server
postbacks. I had some times issues related to validation
or client redirection or other sorts. So i got this
solution and i would like to share it with you.
Here I am presenting a scenario. I have a button,
and OnClick of this button, i want to call java script
function.
On Server Side (.aspx.cs)
--------------------------
Write this code
under Button_Click event or in any server event.
ClientScript.RegisterStartupScript(this.GetType(),
"key", "SubmitConfirm();",true);
You can also pass server control, properties
to the "SubmitConfirm();" function.
On Client Side (.aspx)
--------------------------
write within javascript tag
function SubmitConfirm()
{
alert('Form Submitted and Information Sent to naveedmcp@yahoo.com');
window.location='TestPage.aspx';
}
-------------------------------------