Blog
    C#
    ADO.Net
    .NET
    ASP.Net & Web Forms
    Custom Controls
    Web Development
    Exception Handling
    XML
    Database
    Security in .Net
    Testing
    Web Services
    Windows Services
    Windows Controls
    WCF
    AJAX
    WPF
    XAML
    Reporting
    Setup
    VB.Net
    LINQ
    JQuery
    SilverLight
    JavaScript
    HTML5
    Crystal Report
    Cloud Computing
    Share Point
    Visual C++
    MVC
    Android
    PHP
    Java
    HTML
    WordPress
    Joomla
    Products
    Drupal
    Windows Phone
    JSON
    LightSwitch
    iPhone/iPad
    Ruby on Rails
    IIS 7
    Windows 8
    CSS/CSS3
    Excel
    MS Access
    Shortcut Keys
    Visual SourceSafe
    Team Foundation Server
    API(s)
    Sencha-Touch
    Single Page App
    Bootstrap
Follow Us
Follow _MindStick_ on Twitter View MindStick Software's LinkedIn profile View MindStick Software's Facebook profile
Top Contributor
Advertisement
Advertise with Us
Mindstick
Article Article  Forum Forum  Blog Blog  Quiz Quiz  Beginner Beginner  Careers Careers  Contact Contact  Login Login  
Home | Product | Services | About Us | Interview | DeveloperSection | Submit an Article | Submit Blog
Report Abuse Form
Reason:    
 

Home >> ASP.Net & Web Forms >> Registering Client script in asp.net
Registering Client script in asp.net

In this blog I will give information about client script registration in server side(asp.net).
Views: 4897     Comments: 0
by Rohit Kesharwani on 8/9/2011

Registering Client script in asp.net

Introduction

Client-side script generally refers to the class of computers programs on the web that are executed client side by the user’s browser, instead of the server-side (on the web -server).

Registering Client script from server useful when, you want certain java script to be executed when page finished loading or when user does a submit on the form.

You have a clientscriptmanager object on each aspx page. You have the object name is ClientScript; using ClientScript you can register the script in 4 modes:

1.     RegisterClientScriptBlock() method add the script before the controls are rendered in the page. So the scripts we are registered can't access the controls inside the page.

Example:                             Page.ClientScript.RegisterClientScriptBlock (this.GetType (),

    "RegisterClientScriptBlockMethod"
     "alert ('ScriptBlockRegistered”,      
      true
);

 

2.    RegisterStartupScript() method add the script before the end of body tag after all the controls are rendered in the browser. So the registered script can access the controls inside the page.

Example:                                    Page.ClientScript.RegisterStartupScript (this.GetType (),

        "RegisterStartupScript",

"alert('StartupScriptRegistered'),

 true);

3.    RegisterClientScriptInclude() method refer to an external .js file that includes various script behavior.

Example:                                        Page.ClientScript.RegisterClientScriptInclude(this.GetType(),
                                                                                          "jQuery",
                                                                             "/scripts/jquery.js");

 

4.    RegisterOnSubmitStatement() method registered the script on onSubmit event of a page.

Example:                             Page.ClientScript.RegisterOnSubmitStatement(typeof(string),                                                                                               "onSubmit",  
                                                    "return alert('OnSubmit Registered')");

           

Title :  
Comment :
Text ColorBackground Color
BoldItalicUnderline
LeftCenterRightJustify
Ordered ListBulleted List
IndentOutdent
Horizontal Rule
SubscriptSuperscript
HyperlinkImage
Design ModeDesign
View HtmlHtml
       
 
Report Abuse Form
Reason:    
 
Latest ArticleRSS Feed
    
    
    
    
    
    
    
    
    
    
More...
Latest Blogs by Rohit KesharwaniRSS Feed
    
    
    
    
    
    
    
    
    
    
More...
Top Viewed ArticlesRSS Feed
    
    
    
    
    
    
    
    
    
    
Top Viewed BlogsRSS Feed
    
    
    
    
    
    
    
    
    
    
Latest Interview QuestionsRSS Feed
    
    
    
    
    
    
    
    
    
    
More...
Total Online Users: 5032
  
Copyright © 2014MindStick. All Rights Reserved.