Sunday 9 December 2012

Ajax - ScriptManager Control


1  ScriptManager Control
ScriptManager control is the parent control that needs to be there on every page wherever we are trying to use ASP.NET AJAX controls. ScriptManager control manages client script for AJAX enabled ASP.NET pages. This control enables client script to use the type system extensions and support features for partial page rendering, webservice calls etc.
There are bunch of properties and method associated with ScriptManager control but I am going to show few properties that are oftenly used.
AllowCustomErrorsRedirect
Gets or sets a value that determines whether custom errors section of the web.config file is used during error.
AsyncPostBackErrorMessage
Gets or sets the error message that is sent to the client when an unhandled server exception occurs during an ahynchronous postback.
AsyncPostBackTimeout
Gets or sets the time in seconds before asynchronous postbacks time our if no response is received.
ClientID
Gets the server control identifier generated by ASP.NET (The id for this control that is rendered on the page)
EnablePageMethods
Gets or sets whether public static page methods in asp.net page can be called from client script.
EnableViewState
Gets or sets a value that indicates whether server control persists its viewstate and the viewstate of its child control if any.
IsInAsyncPostBack
Gets or sets a value that indicates whether the current postback is being executed in partial rendering mode.

DEMO : ScriptManager
As written earlier this is a parent control that should be used on every page where we want to use other controls of the ASP.AJAX. A standard code for ScriptManager control will look like following.
<asp:ScriptManager ID="ScriptManger1" runat="Server" EnablePartialRendering="True" />

Source code 
<asp:Content ID="Content1" ContentPlaceHolderID="PlaceHolderHeader" Runat="Server">     </asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="PlaceHolderForTitleAndIntro" Runat="Server">
<div class="ArticleTitle"><h1>ScriptManager Control</h1></div>
<div class="ArticleContents">
ScriptManager control is the parent control that needs to be there on every page wherever we are trying to use ASP.NET AJAX controls.ScriptManager control manages client script for AJAX enabled ASP.NET pages. This control enables client script to use the type system extensions and support features for partial page rendering, webservice calls etc.</div>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="PlaceHolderForContents" Runat="Server">
<div class="ArticleContents">
<p>There are bunch of properties and method associated with ScriptManager control but I am going to show few properties that are oftenly used.</p></div>
<table width="100%" class="TutoPropPlaceHolder" border="1" cellpadding="2" cellspacing="1">
<tr>    <td class="DemoCP">        AllowCustomErrorsRedirect</td>          
    <td> Gets or sets a value that determines whether custom errors section of  web.config file is used during error. </td>
</tr>
<tr>    <td class="DemoCP">AsyncPostBackErrorMessage</td>
    <td>       Gets or sets the error message that is sent to the client when an unhandled server exception occurs during an ahynchronous postback.    </td>                                </tr>
<tr>           <td class="DemoCP">AsyncPostBackTimeout</td>
    <td>  Gets or sets the time in seconds before asynchronous postbacks time our if no response is received.  </td></tr>
<tr>    <td class="DemoCP">ClientID</td>
<td> Gets server control identifier generated by ASP.NET (The id for this control that is rendered on the page) </td></tr>
<tr>    <td class="DemoCP">EnablePageMethods</td>
    <td> Gets or sets whether public static page methods in asp.net page can be called from client script.   </td></tr>
<tr>    <td class="DemoCP">EnableViewState</td>
    <td>  Gets or sets a value that indicates whether server control persists its viewstate and the viewstate of its child control if any.    </td></tr>
<tr>    <td class="DemoCP">IsInAsyncPostBack</td>
<td> Gets or sets a value that indicates whether the current postback is being executed in partial rendering mode. </td>
</tr></table>
 <!-- START - Demo Section -->
        <table class="DemoPlaceHolder" border="1" cellpadding="2" cellspacing="4">
            <tr>              <td class="DemoTitle">                 DEMO : ScriptManager               </td>
                <td align="right">      <a class="DemoShowSource" href="../../misc/codeviewer/default.aspx?pagename=~/tutorials/ajax/scriptmanager.aspx" target="_blank">Show Source Code</a>                   </td>             </tr>
            <tr><td colspan="2">As written earlier this is a parent control that should be used on every page where we want to use other controls of the ASP.AJAX. A standard code for ScriptManager control will look like following.</td>      </tr>
            <tr>     <td colspan="2">
<pre>&lt;asp:ScriptManager ID="ScriptManger1" runat="Server" EnablePartialRendering="True" /&gt;</pre> </td> </tr>
</table>
</asp:Content>                <asp:Content ID="Content4" ContentPlaceHolderID="PlaceHolderFooter" Runat="Server"></asp:Content>
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class tutorials_Ajax_scriptmanager : System.Web.UI.Page                                {
    protected void Page_Load(object sender, EventArgs e)                {
        try          {
            impFunctions.WriteMetaTags(this, "scriptmanager, asp:scriptmanager, scriptmanager tutorials, online scriptmanager control tutorials", "Free online ASP.NET Ajax ScriptManager control tutorials with live demo, source code and downloadable sample project.", false);
            Label lblSiteMap = (Label)this.Master.FindControl("lblSiteMap");
            lblSiteMap.Text = "<a href=\"/default.aspx\" class=\"siteMap\">Home</a> > <a href=\"/tutorials/\" class=\"siteMap\" title=\"Tutorials Home\">Tutorials</a> > <a href=\"/tutorials/ajax\" class=\"siteMap\">ASP.NET AJAX Tutorials</a> > ScriptManager Control ";                        }
        catch { }            }
}

No comments:

Post a Comment