blog

Home / DeveloperSection / Blogs / Server Control in ASP.NET

Server Control in ASP.NET

priyanka kushwaha2413 18-Feb-2015

In this blog, I’m explaining about server control  in .Net

 ASP.Net uses five types of web controls,which are:


1.      HTML controls

2.      HTML  sever controls

3.      ASP.NET server  controls

4.      ASP.NET Ajax Server controls

5.      Use controls and custom controls


ASP.NET server controls are the primary controls used in ASP.NET. These controls can be grouped into the following categories

Validation controls: These are used to validate use input and they work by running client-side script.

Data source controls: These controls provides data binding to different data sources.

Data view controls: These are various lists and tables, which can bind to data from data sources for displaying.

Personalization controls: These are used for personalization of a page according to the user perferences, based on user information.

Login and security controls: These controls provide use authentication.

Master pages: These controls provide consistent layout and interface throughout application.

Navigation controls: These controls help in navigation. For example, menus, tree view etc.

Rich controls: These controls implement special features. For example. AdRotator, fileupload and calendar control.

Syntax of server controls
<asp:controltype ID=”controlID” runat=”server” property1=value1 property2=value2>
AJAX server controls

AJAX= Asynchronous Java script and XML.

AJAX is  technique for creating fast and dynamic web pages.

AJAX, i.e. Asynchronous Javascript and XML, is the technique that can be used to have communication between the client  and server without needing a postback. The benefit of avoiding  postback is faster response to the use,  the page in the browser is not changed/refreshed posted so the  user can continue to use it while data is sent to the server and user  actions like keypresses can  also be communicated to the  server to provide more meaningful result.

Ajax is a set of W3C complaint technologies that  facilitate asynchronous communication between the client and server.

The  controls provided by ASP.NET for having AJAX functionality are

1.      ScriptManager
2.      ScriptManagerProxy
3.      UpdatePanel
4.      UpdateProgress
5.      Timer
ScriptManager Control

The ScriptManager Control is a non visual component on the page. It manages client script for  AJAX-enable ASP.NET web pages.

ScriptManagerProxy

ScriptManagerProxy should be used on content pages that have master pages containing a scriptmanager control. It can also be used inside usercontrol when the page containing the UserControl already has the  ScriptManager control.

UpdatePanel Control

This is a container control that contains other ASP.NET controls. It performs partial-page updates and identifies content that is updated independently of the reset of the page.

UpdateProgress Control

The  UpdateProgress control provides a sort of feedback on the browser while one or more update panel controls are being update.

Timer Control

It performs postback at defined intervals. If you use the timer control with  an UpdatePanel control, you can enable partial-page updates at a defined interval.

  <asp:TimerID="Timer1"runat="server"Interval="2000"></asp:Timer>
Example:
1.       Create a master page
<%@MasterLanguage="C#"AutoEventWireup="true"CodeBehind="MasterPage.master.cs"Inherits="AjaxExample.MasterPage"%>
 
<!DOCTYPEhtml>
 
<htmlxmlns="http://www.w3.org/1999/xhtml">
<headrunat="server">
    <title></title>
    <asp:ContentPlaceHolderID="head"runat="server">
    </asp:ContentPlaceHolder>
</head>
<body>
 
    <formid="form1"runat="server">
         <divstyle="margin-left: 40px">
        <asp:ScriptManagerID="ScriptManager1"runat="server"></asp:ScriptManager>
         <asp:ContentPlaceHolderID="ContentPlaceHolder1"runat="server">
          </asp:ContentPlaceHolder>
        </div>
    </form>
</body>
</html> 


2.   Create .aspx file 

<%@PageTitle=""Language="C#"MasterPageFile="~/MasterPage.Master"AutoEventWireup="true"CodeBehind="AjaxPage.aspx.cs"Inherits="AjaxExample.AjaxPage"%>
 
<asp:ContentID="Content1"ContentPlaceHolderID="head"runat="server">
</asp:Content>
<asp:ContentID="Content2"ContentPlaceHolderID="ContentPlaceHolder1"runat="server">
    <asp:ScriptManagerProxyID="ScriptManagerProxy1"runat="server"></asp:ScriptManagerProxy>
 
    <asp:TimerID="Timer1"runat="server"Interval="2000"></asp:Timer>
    <asp:UpdatePanelID="UpdatePanel1"runat="server">
        <Triggers>
            <asp:AsyncPostBackTriggerControlID="Timer1"EventName="Tick"/>
        </Triggers>
        <ContentTemplate>
            <asp:AdRotator
                ID="AdRotator1"
                AdvertisementFile="~/XMLFile.xml"
                runat="server"Target="_top"Width="500px"/>
 
        </ContentTemplate>
    </asp:UpdatePanel>
    
    <asp:UpdateProgressID="UpdateProgress1"runat="server"DynamicLayout="true"AssociatedUpdatePanelID="UpdatePanel1">
        <ProgressTemplate>
 
            <asp:PanelID="PnlMain"runat="server"GroupingText="Login form"Direction="RightToLeft"HorizontalAlign="Center">
                <table>
                    <tr>
                        <td>user Name</td>
                        <td>
                            <asp:TextBoxID="txtUser"runat="server"></asp:TextBox></td>
                    </tr>
                    <tr>
                        <td>user Password</td>
                        <td>
 
                            <asp:TextBoxID="txtPass"runat="server"contentPlaceHoler="Enter password"></asp:TextBox></td>
                    </tr>
 
                </table>
 
            </asp:Panel>
        </ProgressTemplate>
    </asp:UpdateProgress>
   
 
</asp:Content> 


3.      Create a xml file

 

<?xmlversion="1.0"encoding="utf-8" ?>
<Advertisements>
  <Ad>
    <ImageUrl>~/images/A.jpg</ImageUrl>
    <width>40px </width>
    <height>50px</height>
    <NavigateUrl>http://www.pastelspace.com/image_detail.php?id=1228</NavigateUrl>
 
    <AlternateText>DotNetCurry Home Page</AlternateText>
    <Impressions>40</Impressions>
    <Keyword>small1</Keyword>
  </Ad>
  <Ad>
    <ImageUrl>~/images/B.jpg</ImageUrl>
    <width>40px </width>
    <height>50px</height>
    <NavigateUrl>http://www.pastelspace.com/image_detail.php?id=1034</NavigateUrl>
    <AlternateText>DotNetCurry Home Page</AlternateText>
    <Impressions>40</Impressions>
    <Keyword>small2</Keyword>
  </Ad>
  <Ad>
    <ImageUrl>~/images/C.jpg</ImageUrl>
    <width>40px</width>
    <height>50px</height>
    <NavigateUrl>http://www.dotnetcurry.com</NavigateUrl>
    <AlternateText>DotNetCurry Home Page</AlternateText>
    <Impressions>40</Impressions>
    <Keyword>small</Keyword>
  </Ad>
</Advertisements>

 

You want to read HTML server control,         Server Side environment


Updated 18-Feb-2015

Leave Comment

Comments

Liked By