Tuesday, May 20, 2014

Different between the ASP.NET Server control & HTML controls

ASP.NET server control retains state.
HTML controls do not retain state across post backs.
Example  :-
WebForm1.aspx  :-
 <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm4.aspx.cs" Inherits="FirstApplication.WebForm4" %>  
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
 <html xmlns="http://www.w3.org/1999/xhtml">  
 <head runat="server">  
   <form id="form1" runat="server">  
     ASP.NET Server Control :<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>  
     <br />  
     <br />  
     HTML Control :&nbsp;&nbsp;&nbsp;  
     <input id="Text1" type="text"/><br />  
     <br />  
     <br />  
     <asp:Button ID="Button1" runat="server" Text="Button" />  

An HTML control can be converted in ASP.NET server control by adding runat=”server” attribute in the HTML source.

No comments:

Post a Comment