Home > Asp.net, Javascript > Calling Javascript From Asp.net Codebehind in .aspx.cs

Calling Javascript From Asp.net Codebehind in .aspx.cs


Many times we need to invoke javascript function in codebehind of asp.net page ie. in .aspx.cs page.

There are many ways to accomplish this.

I will provide you a link which will show you how to invoke javascript in master and content page of asp.net

http://www.dotnetcurry.com/ShowArticle.aspx?ID=273

Other ways are as follows:

in .aspx.cs write following code:

Page.ClientScript.RegisterStartupScript(this.GetType(), “alert”, “Disconnect();”, true);

in .aspx write following code:

<script type=”text/javascript” language=”javascript”>

function Disconnect()
{
alert(‘Sucessfully Disconnected’);

}

</script>

Other way is:

Response.Write(“<script>alert(Successfully Disconnected”)</script>”);

Refer another good article at :
http://www.codedigest.com/Articles/ASPNET/314_Multiple_Ways_to_Call_Javascript_Function_from_CodeBehind_in_ASPNet.aspx

Advertisements
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: