ASP.NET

1. ASP.NET Introduction 2. Comp of .Net Framework 3.5 3. Sys.Req for VS 2008 4. ASP.NET Envrmnt Setup 5. VS2010 Ultimate Sys.Req 6. Installing VS 2010 7. VS 2012 Sys.Req 8. Installing VS Exp 2012 9. Start the VS 2008 10. Application Life Cycle 11. Page Life Cycle 12. Page Life Cycle Events 13. ASP.NET Example 14. Event Handling 15. Default Events 16. Server Side 17. Request Object 18. Response Object 19. Server Controls 20. Server Controls Properties 21. Server Controls Methods 22. HTML Server Controls 23. Client Side 24. ASP.NET Basic Controls 25. TextBox Control 26. CheckBox Controls 27. RadioButton Controls 28. ListBox Control 29. HyperLink Control 30. Image Control 31. BulletedList Control 32. ASP.NET Directives 33. Implements Directive 34. Master Type Directive 35. Page Directive 36. PreviousPage Type 37. Managing State 38. Control State 39. Cookies 40. Query Strings 41. Server-Side State 42. Session State 43. Validation Controls 44. Required FieldValidator 45. Range Validator 46. Compare Validator 47. RegularExpressionValidator 48. Custom Validator 49. Validation Summary 50. Data Source Control 51. AdRotator Control 52. Calendar Control 53. Calendar Control Example 54. Panel Control 55. Panel Control Example 56. Multi Views Control 57. MultiView & View controls 58. MultiView Control Example 59. FileUpload Control 60. FileUpload Control Eg 61. AJAX Control 62. UpdatePanel control 63. UpdateProgress Control 64. Custom Controls 65. Custom Control Eg 66. Personalization 67. Create Simple Profile 68. ADO.NET 69. ADO.NET Objects 70. DataTable 71. DataRow 72. DataColumn 73. Object Example 74. Error Handling 75. Tracing Errors 76. Debugger 77. Security 78. Authentication 79. Authorization 80. LINQ 81. LINQ Query Operators 82. LINQ Example 83. Caching 84. Data Caching 85. Output Caching 86. Object Caching 87. Web Services 88. Create Web Services Eg 89. Web & Machine.config 90. Settings Schema 91. ASP.NET Deployment 92. XCopy Deployment 93. Web Setup Project 94. ASP Interview Part 1 95. ASP Interview Part 2 96. ASP Interview Part 3 97. ASP Interview Part 4 98. ASP Interview Part 5 99. ASP Interview Part 6
Pr.Pg Next Pg

ASP.NET HTML Server Controls tutorials

 

ASP .NET HTML Server Controls

  • The HTML server controls are Hypertext Markup Language (HTML) elements that include a runat=server attribute.

  • The HTML server controls have the same HTML output and the same properties as their corresponding HTML tags. In addition, HTML server controls provide automatic state management and server-side events.

  • HTML server controls offer the following advantages:

    1. The HTML server controls map one to one with their corresponding HTML tags.

    2. When the ASP.NET application is compiled, the HTML server controls with the runat=server attribute are compiled into the assembly.

    3. Most controls include an OnServerEvent for the most commonly used event for the control. For example, the <input type=button> control has an OnServerClick event.

    4. The HTML tags that are not implemented as specific HTML server controls can still be used on the server side; however, they are added to the assembly as HtmlGenericControl.

    5. When the ASP.NET page is reposted, the HTML server controls keep their values.

 

  • For example, To use an HTML server control, use the following syntax (which uses the HtmlInputText control as an example):

<input type=”text” value=”hello world” runat= server />

 

  • The following table describes the HTML server controls:

 

ControlName

Description

HtmlAnchor Control

Creates a server-side control that maps to the<a> HTML element and allows you link to another Web page.

HtmlButton Control

Creates a server-side control that maps to the<button> HTML element and allows you create push buttons.

HtmlForm Control

Creates a server-side control that maps to the<form> HTML element and allows you to create a container for elements in a Web page

HtmlImageControl

Creates a server-side control that maps to the<img> HTML element and allows you to display an image

HtmlInputButton Control

Creates a server-side control that maps to the<input type=button>,<input type=submit>, and <input type=reset>HTML elements and allows you to create a command button, submit button, or reset button, respectively.

HtmlInputCheckBox Control

Creates a server-side control that maps to the<input type=checkbox>HTML element and allows you to a create check box control that lets the user select a true or false state.

HtmlInputFile Control

Creates a server-side control that maps to the<input type=file> HTML element and allows you to upload a file to the server.

HtmlInputHidden Control

Creates a server-side control that maps to the<input type=hidden>HTML element and allows you to store information in a non viewable control on the form.

HtmlGenericControl

Creates a server-side control that maps to an HTML element not represented by a specific .NET Framework class, such as <body> and<div>

HtmlInputImage Control

Creates a server-side control that maps to the<input type=image>HTML element and allows you to create an button that displays an image.

HtmlInputRadioButton Control

Creates a server-side control that maps to the<input type=radio>HTML element and allows you to create a radio button on a Web page.

HtmlInputText Control

Creates a server-side control that maps to the<input type=text> and<input type=password>HTML elements and allows you to create a single line text box to receive user input.

HtmlTable Control

Creates a server-side control that maps to the<table> HTML element and allows you to create a table

HtmlTableCell Control

Creates a server-side control that maps to the<td> and <th> HTML elements and allows you manipulate a cell in a table.

HtmlTableRow Control

Creates a server-side control that maps to the<tr> HTML element and allows you to create and manipulate a row in a table.

HtmlTextArea Control

Creates a server-side control that maps to the<textarea> HTML element and allows you create a multiline text box.

HtmlSelect Control

Creates a server-side control that maps to the<select> HTML element and allows you to create a list control.

 

Example:

  • The following example uses a basic HTML layout. It uses some text boxes for getting input from the users like, EmployeeName,Mobile,Address etc. It also has a button control, which is clicked to get the user data for displayed, and a level control for displaying the data on the level.

HTMLcontrols.aspx.cs Code:

 

 

Following simple example shows the use of ASP.NET HTML Server Controls :

Sam Sir

 

using System;

using System.Collections;

using System.Configuration;

using System.Data;

using System.Linq;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.HtmlControls;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Xml.Linq;

 

public partial class HTMLcontrols : System.Web.UI.Page

{

protected void Page_Load(object sender, EventArgs e)

{

 

}

protected void btnsubmit_Click(object sender, EventArgs e)

{

string mystr = "";

mystr += Txtempname.Value + "<br/>";

mystr += Txtmobile.Value + "<br/>";

mystr += Txtaddress.Value + "<br/>";

display_details.InnerHtml = mystr;

}

}

 

 

 

HTMLcontrols.aspx Code:


 

Following simple example shows the use of ASP.NET HTML Server Controls :

Sam Sir

 

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="HTMLcontrols.aspx.cs" Inherits="HTMLcontrols" %>

 

<!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 id="Head1" runat="server">

<title>HTML Server Control</title>

 

<style type="text/css">

.style1

{

width: 100%;

}

</style>

 

</head>

<body>

<form id="form1" runat="server">

 

<table class="style1">

<tr>

<td>

&nbsp;</td>

<td>

HTML Server Control Example</td>

</tr>

<tr>

<td align="right">

Employee Name:</td>

<td>

<input id="Txtempname" type="text" runat="server" /></td>

</tr>

<tr>

<td align="right">

Mobile:</td>

<td>

<input id="Txtmobile" type="text" runat="server" /></td>

</tr>

<tr>

<td align="right">

Address:</td>

<td>

<input id="Txtaddress" type="text" runat="server" /></td>

</tr>

<tr>

<td>

&nbsp;</td>

<td>

<input id="Submit1" type="submit" value="submit" runat="server" onserverclick="btnsubmit_Click" onclick="return Submit1_onclick()" /></td>

</tr>

<tr>

<td>

&nbsp;</td>

<td id="display_details" runat="server">

&nbsp;</td>

</tr>

</table>

</form>

</body>

</html>

Output

 

 

asp.net html server control example

 

Pr.Pg border                                              Next Pg