dcsimg
Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


Tip of the Day
Language: .NET
Expertise: Beginner
Nov 12, 2007

WEBINAR:

On-Demand

Building the Right Environment to Support AI, Machine Learning and Deep Learning


Invoking a Client-side JavaScript Function from the Server-side Code

.NET allows you to call a JavaScript function from the server-side code. For example, suppose you want to to display a message box to the user. This can be accomplished in two steps:
  1. Write a JavaScript function in the HTML view of the page inside the <HEAD></HEAD> elements as shown below:
    
    <script language="javascript">
    	function ShowAlert()
    	{
    	   alert('Invoking from the server side code.');
    	}
    </script>
    
  2. In the code behind file of the .aspx page, add the following line of code in the page load function:
    
         private void Page_Load(object sender, System.EventArgs e)
         {
            Button1.Attributes.Add("OnClick", "ShowAlert();");
         }
    
Now, compile the project and run it. Clicking the button on the page, you can see the message box displayed.

Deepak Choudhari
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date