runs on the server under the control of the ASP.NET worker process (asp_wp.exe), which runs in conjunction
with IIS. The content portion of the Web form resides in a content directory of the Web server,
ASP.NET Web Application have basically three parts as:
Content
Content files determine the appearance of a Web application. They can contain static text and images as well as
elements that are composed on the fly by the program logic (as in the case of a database query).
Types of files:
Web forms, HTML, images, audio, video, other data
Configuration
The configuration files and settings determine how the application runs on the server, who has access, how errors are
handled, and other details.
Types of files:
Web configuration file, style sheets, IIS settings
The Web form is the key element of a Web application. A Web form is a cross between a regular HTML
page and a Windows form. It has the same appearance as and similar behavior to an HTML page, but it
also has controls that respond to events and run code, like a Windows form.
In a completed Web application, the executable portion of the Web form is stored in an assembly (.dll) that
runs on the server under the control of the ASP.NET worker process (asp_wp.exe), which runs in conjunction
with IIS. The content portion of the Web form resides in a content directory of the Web server.
When a user navigates to one of the Web forms from his or her browser, the following sequence occurs:
IIS starts the ASP.NET worker process if it is not already running. The ASP.NET worker process loads
the assembly associated with the Web form.
The assembly composes a response to the user based on the content of the Web form that the user
requested and any program logic that provides dynamic content.
IIS returns the response to the user in the form of HTML.
Once the user gets the requested Web form, he or she can enter data, select options, click buttons, and use any
other controls that appear on the page. Some controls, such as buttons, cause the page to be posted back to the
server for event processing, and the sequence repeats itself
Executable portions of a Web application compiled so they execute more quickly than interpreted scripts
On-the-fly updates of deployed Web applications without restarting the server
Access to the .NET Framework, which simplifies many aspects of Windows programming
Use of the widely known Visual Basic programming language, which has been enhanced to fully support
object-oriented programming
Introduction of the new Visual C# programming language, which provides a type-safe, object-oriented
version of the C programming language
Automatic state management for controls on a Web page (called server controls) so that they behave
much more like Windows controls
The ability to create new, customized server controls from existing controls
Built-in security through the Windows server or through other authentication/authorization methods
Integration with ADO.NET to provide database access and database design tools from within Visual
Studio .NET
Full support for Extensible Markup Language (XML), cascading style sheets (CSS), and other new
and established Web standards
Built-in features for caching frequently requested Web pages on the server, localizing content for specific
languages and cultures, and detecting browser capab
Here's how to set the active row of a DataGridView. The two example variables will be dataGrid, which is
a DataGridView, and index, which is the index of the row you want to select with C# code.
First is to scroll down the DataGridView so the row is visible in the screen:
dataGridView1.FirstDisplayedScrollingRowIndex = index; dataGridView1.Refresh();
Then you must select the row so that binding sources update their Current item:
dataGridView1.CurrentCell = dataGrid.Rows[index].Cells[0];
Finally, you can visually select the row with C#:
dataGridView1.Rows[index].Selected = true;
The C# code above assumes that you are trying to select an entire DataGridView row. However it is simple
to adjust if you just want to select a Cell. Otherwise the code will work to set the DataGridView selection.
<script language="C#" runat="server"> public void button1_Click(object sender, EventArgs e) { label1.Text = "Hello World!!!"; } </script>
<asp:Label id="label1" runat="server"/> <br><br> <asp:button id="button1" text="Hit" OnClick="button1_Click"
runat="server" />
<%@ Register TagPrefix="UC" TagName="TestControl"
Src="test.ascx" %>
<html> <body> <form runat="server"> <UC:TestControl id="Test1" runat="server"/> </form> </body> </html>
// Load the control by calling LoadControl on the page class. Control c1 = LoadControl("test.ascx"); // Add the loaded control in the page controls collection. Page.Controls.Add(c1);
System System.Collections System.ComponentModel System.Data System.Web System.Web.SessionState System.Web.UI System.Web.UI.WebControls
public class SimpleServerControl : Control
protected override void Render(HtmlTextWriter writer) { writer.Write("Hello World from custom control"); }
<%@ Register TagPrefix="CC" Namespace="CustomServerControlsLib
" Assembly="CustomServerControlsLib " %>
<form id="Form1" method="post" runat="server"> <CC:SimpleServerControl id="ctlSimpleControl"
runat="server"> </CC:SimpleServerControl > </form>
public class SimpleServerControl : Control { private int noOfTimes; public int NoOfTimes { get { return this.noOfTimes; } set { this.noOfTimes = value; } } protected override void Render (HtmlTextWriter writer) { for (int i=0; i< NoOfTimes; i++) { write.Write("Hello World.."+"<BR>"); } } }
<CC:SimpleServerControl id="ctlSimpleControl" NoOfTimes="5"
runat="server"></CC:SimpleServerControl>
[ // Specify the default property for the control. DefaultProperty("DefaultProperty"), // Specify the tag that is written to the aspx page when the // control is dragged from the Toolbox to the Design view. //However this tag is optional since the designer automatically // generates the default tag if it is not specified. ToolboxData("<{0}:ControlWithAttributes runat=\"server\">" + "</{0}:ControlWithAttributes>") ] public class ControlWithAttributes : Control { private string _defaultProperty; public string DefaultProperty { get { return "This is a default property value";} set { this._defaultProperty = value; } } protected override void Render(HtmlTextWriter writer) { writer.Write("Default Property --> <B>" + DefaultProperty + "</B>"); } }
[assembly:TagPrefix("ServerControlsLib ", "MyControl")]
<script language="C#" runat="server"> public void button1_Click(object sender, EventArgs e)
{
label1.Text = "Hello World!!!";
}
</script>
<asp:Label id="label1" runat="server"/>
<br><br>
<asp:button id="button1" text="Hit" OnClick="button1_Click"
runat="server" />
<%@ Register TagPrefix="UC" TagName="TestControl"
Src="test.ascx" %>
<html>
<body>
<form runat="server">
<UC:TestControl id="Test1" runat="server"/>
</form>
</body>
</html>
// Load the control by calling LoadControl on the page class. Control c1 = LoadControl("test.ascx"); // Add the loaded control in the page controls collection. Page.Controls.Add(c1);
System System.Collections System.ComponentModel System.Data System.Web System.Web.SessionState System.Web.UI System.Web.UI.WebControls
public class SimpleServerControl : Control
protected override void Render(HtmlTextWriter writer) { writer.Write("Hello World from custom control"); }
<%@ Register TagPrefix="CC" Namespace="CustomServerControlsLib
" Assembly="CustomServerControlsLib " %>
<form id="Form1" method="post" runat="server"> <CC:SimpleServerControl id="ctlSimpleControl"
runat="server"> </CC:SimpleServerControl > </form>
public class SimpleServerControl : Control { private int noOfTimes; public int NoOfTimes { get { return this.noOfTimes; } set { this.noOfTimes = value; } } protected override void Render (HtmlTextWriter writer) { for (int i=0; i< NoOfTimes; i++) { write.Write("Hello World.."+"<BR>"); } } }
<CC:SimpleServerControl id="ctlSimpleControl" NoOfTimes="5"
runat="server"></CC:SimpleServerControl>
[ // Specify the default property for the control. DefaultProperty("DefaultProperty"), // Specify the tag that is written to the aspx page when the // control is dragged from the Toolbox to the Design view. //However this tag is optional since the designer automatically // generates the default tag if it is not specified. ToolboxData("<{0}:ControlWithAttributes runat=\"server\">" + "</{0}:ControlWithAttributes>") ] public class ControlWithAttributes : Control { private string _defaultProperty; public string DefaultProperty { get { return "This is a default property value";} set { this._defaultProperty = value; } } protected override void Render(HtmlTextWriter writer) { writer.Write("Default Property --> <B>" + DefaultProperty + "</B>"); } }
[assembly:TagPrefix("ServerControlsLib ", "MyControl")]