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 Basic Controls tutorials

The following controls show the Basic Web Controls:

Button Controls

  • Button controls are controls that post the form back to the server, enabling server-side processing to commence. There are three types of ASP.NET button controls, all members of the System.Web.UI.WebControls namespace:

    1. Button: This is the standard button.

    2. LinkButton: The LinkButton control is a cross between a standard button and aHyperLink control. A LinkButton appears to the user as a hyperlink (i.e., the text is colored and underlined), but it performs the standard postback behavior.

    3. ImageButton: The ImageButton control performs the same function as the standard button, except that an image bitmap takes the place of the button on the browser UI. For the ImageButton control, there is no Text attribute but there is an AlternateText attribute, which specifies what text to display on non graphical browsers instead of the image.

Syntax of Button Controls is:

<asp:Button ID="Button1" runat="server"

onclick="Button1_Click" Text="Click" />

  • In addition to all the properties, methods, and events inherited from WebControl, all three button types have the following two events:

Click: This event is raised when the control is clicked and no command name is associated with the Button (i.e., no value has been assigned to the Buttoncontrol's CommandName property). The method is passed an argument of typeEventArgs.

Command: This event is raised when the control is clicked and a command name such asSort or Select has been assigned to the Button control's CommandName property. The event is passed an argument of type CommandEventArgs, which has these two members:

CommandName: The name of the command.

CommandArgument: An optional argument for the command set in the Button control'sCommandArgument property. You could then write a single method to handle the Command event for all the Button controls on your page and have it take its cue from the differing CommandName and CommandArgument values assigned to the different buttons.

  • Common Properties of the Button control:

 

Properties

Description

CausesValidation

Page is validated when a button is clicked

CommandArgument

Determine additional information about the command to perform

CommandName

Specifies the command associated with the Command event

onClientClick

Specifies the name of the function to be executed when a button is clicked by the user

PostBackUrl

Determines the URL of the page to post to from the current page when a user clicked the button

runat

Specifies that the control is a server control, Must be set to "server"

Text

Determines the text displayed by a button

UseSubmitBehavior

Determines whether or not a button uses the browser's submit mechanism or the ASP.NET postback mechanism

ValidationGroup

Determines the group of controls a button causes validation, when it posts back to the server

Example:

ButtonControl.aspx.cs Code:

 

Following example shows the use of ASP.NET Basic Web Controls(Button 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 ButtonControl : System.Web.UI.Page

{

protected void Page_Load(object sender, EventArgs e)

{

 

}

 

protected void button1_Click(object sender, EventArgs e)

{

button1.Text = "This is button server control";

}

}

 

 

 

ButtonControl.aspx Code:

 

Following example shows the use of ASP.NET Client Side Controls:

Sam Sir

 

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

 

<!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">

<title>cbtSAM ASP.NET Client side Control Example</title>

</head>

<body>

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

<div>

<asp:Button id="button1&uuot; Text="Click the Button" runat="server"

onclick="button1_Click" />

</div>

</form>

</body>

</html>

Output

 

 

After running the web forms it will display a button after click the button it will display following:

asp.net basic control example

 

Pr.Pg border                                              Next Pg