Asp Notes
Asp Notes
Asp Notes
Net
What is ASP.NET? ASP.NET is a powerful and flexible server side technology, which is used for developing dynamic Web pages. The heart of ASP.NET technology is Microsofts .NET Framework, which provides the core technology. The .NET framework contains a vast set of programming classes designed to satisfy any programming needs and ASP.NET is just one of the components. The .NET framework is designed to help and solve several fundamental problems and issues faced by the programmers such as:
It leads to time saving while building large, reliable applications. It allows programmers of different languages to work on applications. It provides an easier, cheaper and faster way to get efficient programs into the hands of the user. It allows programmers to unify two kinds of architectures- applications that run locally on the machine and applications that are accessed over the Web. Using .Net there is no need to write a complex code with complicated languages to get impressive results.
The .NET Framework Class Library Imagine that you have to support multiple programming languages - such as Visual Basic, and C++. Many of these languages overlap. For example, for each language, you have to include methods for accessing the file system, working with databases, using different methods and manipulating strings. Furthermore these programming languages have similar programming constructs. For example every language can represent loops and conditionals. Even though the syntax of a conditional, written in Visual Basic differs from that written in C++, the programming functions the same. Finally, most programming languages have similar types of variable data. In most languages, you have some means of representing strings and integers. For example, the maximum and minimum size of an integer may depend on the language, but the basic type of data is the same. It requires a lot of work to maintain this functionally for multiple languages. Therefore .NET Framework consists of a vast set of classes designed to satisfy any conceivable programming need.
For example the .NET Framework contains classes for handling database access, working with the file system, manipulating text, and generating graphics. In addition, it contains more specialized classes for performing tasks, such as working with regular expressions and handling network protocols. The .NET Framework also contains classes that represents all basic variable data types such as strings, integers, bytes, characters and arrays. The motive here is to explain that you can access any of .NET Framework classes even when you are building your ASP.NET pages. Understanding Namespaces The .NET Framework contains thousand of classes (over 3500). Fortunately, the classes are not simply jumbled together but they are organized into a hierarchy of namespaces. You can define namespace as a logical grouping of classes. For example; all the classes that relate to working with the file systems are gathered together into the System.IO namespace. Avoiding Confusion Between ASP and ASP.NET These terms must first be understood as separate and distinct, before installing and running ASP.NET. These can be defined as: ASP A server side technology for creating dynamic web pages using script language only. ASP.NET A server side technology for creating dynamic Web pages that allows the use of any full fledged programming language supported by .NET.
4 In asp.net we can configure each application using web.config file which is availble in application itself and we have machine.config wherer we can configure all applications. In asp we cannot configure single application 5 Asp.net we have autopostback event which is not in asp 6 We have well built GUI to work in asp.net. 7 We have ado.net and as well as disconnected architecture in asp.net. 8. We can work with any language as code behind technique in asp.net that supports .net frame work . 9. ASP: Business Logic and Presentation Logic are in a single file ASP.NET: Business Logic and Presentation Logic are in Separate files (.cs or .vb) and (.aspx) respectively. 10. ASP: No Web Server Controls ASP.NET: Web Server Controls supported by strong .NET Framework 11. ASP: No RAD in Classic ASP while ASP.NET: Supports RAD Example1: SimpleHtmlPage.aspx <html> <head><title>This is a Simple HTML Page</title></head> <body> <form method=post action=SimpleHtmlPage.aspx> <b>Your Name:</b> <br><input name=username type=text size=25> <p> <b>Your Comments:</b> <br><textarea rows=10></textarea> <p> <input type=submit value=Send Comment> </form> </body> </html> name=comments cols=55
The output of this page is shown below. You might notice that the HTML form posts back to itself (through the action attribute). So when the Send button is clicked, the same form appears once again. The HTML form in Example 1 does not contain any ASP.NET controls. When you type something in the form and click the Send Comment button, the data you enter into the form disappears every time.
We can modify Example 1 so that it uses ASP.NET controls rather than the HTML form element. This will convert the form fields into smart server side form fields. Modify the page according to the Example 2 and save it with the name SimpleAspxPage.aspx in the same directory. Example2: SimpleAapxPage.aspx <html> <head><title>This is a Simple ASPX Page</title></head> <body>
<form runat="Server"> <b>Your Name:</b> <br><input id="username" type="text" size="25" runat="Server"> <p> <b>Your Comments:</b> <br><textarea id="comments" cols=60 rows=10 runat="Server"></textarea> <p> <input type="submit" value="Send Comment" runat="Server"> </form> </body> </html>
The output of this page is shown below. In this example four modifications were made:
The page is renamed as SimpleAspxPage.aspx. The Attribute Runat=Server is added to all the form tags. For Example, instead of using <input name=username type=text size=25>, the following is used - <input id="username" type="text" size="25" runat="Server">
The Runat=Server attribute converts these standard HTML tags into smart server side HTML tags. When SimpleAspxPage.aspx page is opened in the Web browser, the <form runat="Server"> tag executes on the server before any content is rendered to the Web browser. The Runat=Server attribute converts these standard HTML tags into ASP.NET controls.
Note that instead of using the name attribute to name the form fields, a unique identifier is given with ID attribute. This is because you are no longer treating the form fields as simple HTML tags; but you are converting the form field into server side objects.
Note that Example 1 was modified so that one can submit the HTML form using: standard, <form
Therefore it is clear that if you want to convert any of the form fields within a HTML form into ASP.NET controls you must use the Runat=Server attribute with the opening form tag. The Method attribute of the form tag is not used with the control version of the form tag. By default, the ASP.NET HTML Form control includes this attribute. Action attribute is not specified. The ASP.NET HTML Form control automatically posts back to the same way as the original form tag. In brief, to convert a standard HTML file into an ASP.NET page, you make four modifications to the page as discussed above. Now you have converted an HTML page to a smart ASP.NET page. The method to get out of it is discussed below: Open the page SimpleAspxPage.aspx in the browser and try to submit the form. All the data is preserved between the form posts. When the form is posted over and over again the form data does not disappear.
ASP.NET controls represent the HTML elements of a page in an intuitive object model. ASP.NET controls, automatically retain the value of their properties by participating in view state (view state will be explained in the next section). ASP.NET controls enable you to separate the design content of a page from the application logic. ASP.NET controls enable you to maintain browser compatibility while still supporting advanced browser features such as JavaScript.
This directive appears on the top of an ASP.NET page. It specifies which programming language is being used to write an ASP.NET page. For example if we want to use VB as our page language, we will use the following directive: <%@ Page Language=VB%>
And if it is C# then we use the following directive: <%@ Page Language="VB" %> <script runat="server"> Sub tbMessage_Change (Sender as Object, E as EventArgs) lblMessage. Text="Hello " + tbMessage. Text End Sub </script> <html> <body> <font size="5">www.expertrating.com</font><hr><p> <% Response.Write ("Our Test Page<p>") %> <form runat="server"> Please Enter Your Name: <asp: TextBox id="tbMessage" OnTextChanged ="tbMessage_Change" runat="server"/> <asp: button id="btSubmit" Text="Submit" runat="server"/><p> <b><asp: label id="lblMessage" runat="server"/></b> </form> </body> </html>
BorderWidth ControlStyle CssClass Enabled Font ForeColor Height Style TabIndex ToolTip Width
Gets/Sets the control's border width Gets the control's style Gets/Sets the control's CSS class Gets/Sets whether the control is enabled Gets/Sets the font for the control Gets/Sets the control's foreground color Gets/Sets the control's height Gets the HTML style of the control as a collection of text attributes Gets/Sets the control's tab index Gets/Sets the control's tool tip text Gets/Sets the control's width
LABEL <html> <head> <script language="C#" runat="server"> private void Button1_Click(Object sender,EventArgs e) Label1.Text Text1.Text; End Sub </script> </head> <body> <h3><font face="Verdana">Label Example</font></h3> <form runat="server"> <asp:Label id="Label1" Text="Label1" runat="server"/> <p> <asp:TextBox id="Text1" Text="Copy this text to the label" runat="server" />
TEXTBOX Programmatic access is provided by the TextBox class located in the System.Web.UI.WebControls namespace. TextBox appearance and behavior may be manipulated via its properties. The following list provides a sampling of the properties:
AutoPostBack: Boolean value signaling whether the AutoPostBack feature is enabled for the control. This determines if the form will automatically be posted back to the Web server when the contents of the field change. BackColor: The background color of the control. This may be controlled with CSS as well. BorderColor: The border color for the border (if used) displayed around the control. BorderWidth: The width of the border around the control on the page. CausesValidation: Boolean value signaling whether validation is performed when postback of form is executed. Columns: The display width of the TextBox control. CssClass: Allows you to assign a CSS class to the control. Font: The various font attributes associated with the control. The preferred approach is to use CSS, but the Font class contains properties for signaling whether the text appears in bold, italic, strikeout, or underline, as well as font size, name, and more. ForeColor: The color of the text displayed in the field. The preferred technique is CSS. Height: Get or set the height of the control. MaxLength: The maximum number of characters allowed in the field. ReadOnly: Boolean value signaling whether control may be edited by user or just read only. Rows: The number of rows for a TextBox using the multiple line setting. SkinId: Allows you to assign a skin to the TextBox to control its appearance. Text: The text contained within the field.
TextMode: The text mode of the control. The legal values are found in the TextBoxMode class with values of single-line, multiline, or password. The password setting masks the text entered, so the password is not displayed it is available in the code for manipulation and storage. Visible: Boolean value signaling whether the control is visible or hidden. Wrap: Boolean value signaling whether text wraps within the field.
The following C# example demonstrates the properties used during a page load. The containing page for the code contains one TextBox control named TextBox1. The code sets the TextBox to multiline and setsfont properties and colors: protected void Page_Load(object sender, EventArgs e) { TextBox1.AutoPostBack = true; TextBox1.BackColor = System.Drawing.Color.LightBlue; TextBox1.BorderWidth = 4; TextBox1.Columns = 80; TextBox1.Font.Bold = true; TextBox1.Font.Italic = false; TextBox1.Font.Size = FontUnit.Larger; TextBox1.ForeColor = System.Drawing.Color.Black; TextBox1.Rows = 40; TextBox1.TextMode = TextBoxMode.MultiLine; TextBox1.Wrap = true; TextBox1.Visible = true; TextBox1.Text = "This is a test."; } protected void TextBox1_TextChanged(object sender, EventArgs e) { Response.Write(TextBox1.Text); } Sample 1 Drag a TextBox and a Button control onto the WebForm. When you click the button some text is displayed in a TextBox. The code for that looks like this: Private Void Button2_Click(Object sender, EventArgs e) { TextBox1.Text = "Welcome to TextBoxes" } Sample2, Multiline TextBox
Drag a TextBox, Button and a Label control onto the form. We will make this TextBox a Multiline textbox and display the text entered in this multiline textbox on a label. Before you proceed, select the textbox, open it's properties window and set it's TextMode property to Multiline. The code to achieve the desired functionality looks like this: Private Void Button2_Click(Object sender, EventArgs e) { Label2.Text = TextBox2.Text } Sample3, Password Character Drag a Textbox, Button and a Label control onto the form. Select the textbox, open it's properties window and set the TextMode property to Password. When you set TextMode property to password, the text you enter in the textbox is masked with asteriks (*). The following code displays the text you entered in the textbox as text for the label. Private Void Button1_Click(Object sender, EventArgs e) { Label1.Text = TextBox1.Text }
ImageButton To set the Image for this control we use the ImageUrl property. Image buttons support both Click and Command events. When we handle Click events, we are passed the actual location of the mouse in the image. We can use Command event handlers to make the image button work like a command button. Sample Drag a Label and an ImageButton Control on to the form and paste the following code: Private Void ImageButton1_Click(Object sender, EventArgs e) { Label1.Text = "You clicked the image button at" & e.X & " " & e.Y End Sub When you run the code and click on the image button, the X and Y coordinates are displayed on the label.
HyperLink <html> <script language="C#" runat="server"> private void Page_Load(Object sender, EventArgs e) { ' Set hyperlink to "~", which indicates application root. HyperLink1.NavigateUrl = "~" } </script> <body> <h3><font face="Verdana">Simple asp:hyperlink Sample</font></h3> <form runat=server> <p> <asp:hyperlink id=HyperLink1 runat="server"> Go To QuickStart </asp:hyperlink> </form> </body> </html> DropDownList The DropDownList control is actually a container for the list items, which are of type ListItem. Each ListItem object is a separate object with its own properties. These properties are described in the following table. Property Description Text Value Specifies the text that is displayed in the list. Contains the value that is associated with an item. Setting this property enables you to associate a value with a specific item without displaying it. For example, you can set the Text property to the name of a color and the Value property to its hexadecimal representation.
Selected
To work with list items programmatically, use the Items collection of the DropDownList control. The Items collection is a standard collection, and you can add item objects to it, delete items, clear the collection, and so on. The currently selected item is available in the DropDownList control's SelectedItem property. <html> <head> <script language="VB" runat="server"> Sub SubmitBtn_Click(sender As Object, e As EventArgs) Label1.Text="You chose: " + DropDown1.SelectedItem.Text End Sub </script> </head> <body> <h3><font face="Verdana">DropDownList Example</font></h3> <form runat=server> <asp:DropDownList id=DropDown1 runat="server"> <asp:ListItem>Item 1</asp:ListItem> <asp:ListItem>Item 2</asp:ListItem> <asp:ListItem>Item 3</asp:ListItem> <asp:ListItem>Item 4</asp:ListItem> <asp:ListItem>Item 5</asp:ListItem> <asp:ListItem>Item 6</asp:ListItem> </asp:DropDownList> <asp:button text="Submit" OnClick="SubmitBtn_Click" runat=server/> <p> <asp:Label id=Label1 Font-Names="Verdana" font-size="10pt" runat="server"> Select a value from the list </asp:Label>
</form> </body> </html> ListBox <html> <head> <script language="C#" runat="server"> void SubmitBtn_Click(Object Sender, EventArgs e) { if (ListBox1.SelectedIndex > -1) { Label1.Text = "You chose: " + ListBox1.SelectedItem.Text; } } </script> </head> <body> <form runat="server"> <h3> <font face="Verdana">ListBox Example</font></h3> <p> <asp:ListBox ID="ListBox1" Width="100px" runat="server"> <asp:ListItem>Item 1</asp:ListItem> <asp:ListItem>Item 2</asp:ListItem> <asp:ListItem>Item 3</asp:ListItem> <asp:ListItem>Item 4</asp:ListItem> <asp:ListItem>Item 5</asp:ListItem> <asp:ListItem>Item 6</asp:ListItem> </asp:ListBox> <asp:Button Text="Submit" ID=submit1 OnClick="SubmitBtn_Click" runat="server" /> <p> <asp:Label ID="Label1" Font-Names="Verdana" FontSize="10pt" runat="server" /> </form> </body> </html> You can add items to a list Web server control in the following three ways:
Add static items at design time. Add items programmatically at run time. Add items using data binding. For details, see How
to: Populate List Web Server Controls from a Data Source. When you add a list item, you specify up to three possible properties of the item. The following table describes these properties. Property Description Text Value Specifies the text displayed in the list. Specifies a value that is associated with an item but is not displayed. For example, you can set the Text property to the name of chemical element and the Value property to the symbol of the element. Indicates whether the item is selected. In a CheckBoxList control and in a multi-selection ListBox control, more than one item can be selected. In a DropDownList control, RadioButtonList control, and single-selection ListBox control, only one item can be selected at a time. If you set more than one selected item in these controls, the browser determines which item is rendered as selected. In a BulletedList control, this setting has no effect. 1. In Design view, select the list control to which you want to add items. In the Properties window, click the ellipsis button ( The ListItem Collection Editor dialog box appears. ) in the Items box.
Selected
2. Click Add to add a new item. 3. Select the new item, and then in the properties grid,
enter values for its Text, Value, and Selected properties.
4. Repeat steps 2 and 3 for each item you want to add, and
then click OK.
1. Create a new object of type ListItem and set its Text and
Value properties. Typically, you create the new ListItem by calling the Add method.
CheckBox and CheckBoxList Object Control WebControl ListControl CheckBoxList You can use two types of Web server controls to add check boxes to an ASP.NET Web page: individual CheckBox controls or a CheckBoxList control. Both controls provide a way for users to specify yes/no (true/false) choices. You add individual CheckBox controls to a page and work with them singly. Alternatively, you can use the CheckBoxList control, which is a single control that acts as a parent control for a collection of check-box list items. It derives from the base ListControl class, and therefore works much like the ListBox, DropDownList, RadioButtonList, and BulletedList Web server controls. Many of the procedures for working with the CheckBoxList control are the same as the procedures for the other list server controls.
Both types of controls have advantages. By using individual CheckBox controls, you get more control over the layout of the check boxes on the page than by using the CheckBoxList control. For example, you can include non-check-box text between each check box. You can also control the font and color of individual check boxes. The CheckBoxList control is a better choice if you want to create a series of check boxes from data in a data source. (You can bind an individual CheckBox control to data.) CheckBox and CheckBoxList Events Events work differently between individual CheckBox controls and the CheckBoxList control.
CheckBox Control Events Individual CheckBox controls raise the CheckedChanged event when users click the control. By default, this event does not cause the page to be posted to the server. However, you can force the control to perform an immediate postback by setting the AutoPostBack property to true. For more information, see How to: Respond to User Selection in a CheckBox Web Server Control. You might not need to create an event handler for the CheckedChanged event. You can test which check box is selected in any code that runs as part of the page. Typically, you create an event handler for the CheckedChanged event only if you need to know that the check box was changed, not just to read the value of a check box. For details, see How to: Set and Get the Selection in a RadioButton Web Server Control. CheckBoxList Control Events The CheckBoxList control raises a SelectedIndexChanged event when users select any check box in the list. By default, the event does not cause the page to be posted to the server. However, you can force the control to
perform an immediate postback by setting the AutoPostBack property to true. Notable Notable properties of the properties CheckBoxList control are as follows:
Items: Gets/Sets the collection of items in the list RepeatColumns: Gets/Sets the number of displayed columns in the check box list RepeatDirection: Gets/Sets the display direction of checkboxes RepeatLayout: Gets/Sets the checkbox layout TextAlign: Gets/Sets the check box's text alignment Image You can specify the graphics file for an Image control at design time or at run time programmatically. You can also bind the control's ImageUrl property to a data source to display graphics based on database information. Unlike most other Web server controls, the Image control does not support any events. For example, the Image control does not respond to mouse clicks. Instead, you can create an interactive image by using the ImageMap or the ImageButton Web server controls. Specifying Text Elements In addition to displaying a graphic, the Image control enables you to specify various types of text for the image, such as the following: 1. ToolTip The text that is displayed in a tooltip in some browsers. The text that is displayed if the graphics file cannot be
2. AlternateText
found. If no ToolTip property is specified, some browsers will use the AlternateText value as a tooltip. To add an Image Web server control to a Web Forms page
<% @ Page Language="C#" %> <script runat="server"> protected void ImageMap1_Click(object sender, ImageMapEventArgs e) { String region = ""; switch(e.PostBackValue) { case "NW": region = "Northwest"; break;
} </script>
case "NE": region = "Northeast"; break; case "SE": region = "Southeast"; break; case "SW": region = "Southwest"; break;
<html> <body> <form id="form1" runat="server"> <div> <asp:Label runat="server" ID="Label1" /> <br /> <br /> <asp:ImageMap ID="ImageMap1" ImageUrl="~/Images/MapTest.PNG" runat="server" HotSpotMode="PostBack" OnClick="ImageMap1_Click"> <asp:RectangleHotSpot Bottom="100" Right="100" HotSpotMode="PostBack" PostBackValue="NW" /> <asp:RectangleHotSpot Bottom="100" Left="100" Right="200" HotSpotMode="PostBack" PostBackValue="NE" /> <asp:RectangleHotSpot Bottom="200" Right="100" Top="100" PostBackValue="SW" /> <asp:RectangleHotSpot Bottom="200" Left="100" Right="200" Top="100" PostBackValue="SE" /> </asp:ImageMap> </div> </form> </body> </html> Literal You can add a Literal Web server control to your Web Forms page when you want to set text programmatically without adding extra HTML tags. The Literal control is useful as a way to add text into a page dynamically without adding any elements that are not part of the dynamic text. For example, you
can use the Literal control to display HTML that you read from a file or from a stream. Encoding Content in the Literal Control The Literal control supports the Mode property, which specifies how the control handles markup that you add to it. You can set the Mode property to these values:
Transform. Any markup that you add to the is transformed to accommodate the
control
protocol of the requesting browser. This setting is useful if you are rendering content to mobile devices that use protocol other than HTML.
control is encoded using the HtmlEncode method, which converts HTML encoding into its text representation. For example, a <b> tag is rendered as <b>. As mentioned above, we can use a literal control to edit the HTML directly in the code designer. The following line of code demonstrates that. Literal1.Text = "<b><u>I am Literal</b></u>"
AdRotator
The AdRotator Web server control can be used to display graphics that are linked to other pages. The list of graphics to be displayed and the associated target links is maintained in a data source such as an XML file or database. This topic contains:
Scenarios
The AdRotator Web server control provides a way to display advertisements (ads) on your ASP.NET Web pages. The control displays a .gif file or other graphic image that you provide. When users click the ad, they are redirected to a target URL that you have specified. The control automatically reads advertisement information, such as the graphic file name and the target URL, from a list of ads that you provide using a data source, which is usually an XML file or a database table. The AdRotator control selects ads randomly, changing the displayed ad each time the page is refreshed. Ads can be weighted to control the priority level of banners, making it possible to have certain ads display more often than others. You can also write custom logic that cycles through the ads. The AdRotator Web server control can be used to display ad graphics such as a .gif or similar image. The user can then be redirected to a target URL. The graphic and target URL can be provided from a data source such as an XML file.
You can store ad information in an XML file that contains references to ad banners and their associated properties. ImageUrl: Specifies the image URL that presents the image for the advertisement NavigateUrl: Specifies the URL of the page to which the user should be taken to when he clicks on the image AlternateText: An optional parameter that specifies the text when the user moves his mouse pointer over the image Keyword: Optional parameter that specifies the keyword (category) like books, programming, etc Impressions: Optional parameter that provides a number that indicates the weight of the ad in the order of rotation with respect to other ads in the file KeywordFilter The KeywordFilter property specifies a keyword to filter for specific types of advertisements in the XML advertisement file. Each advertisement in the XML advertisement file can be assigned a category keyword. The KeywordFilter property filters the advertisements for the specified keyword. Only advertisements containing the keyword will be selected for the AdRotator control and it is not possible to specify more than one keyword in the
KeywordFilter property, nor it is possible to declare multiple keywords in the advertisement file. Filtering Ads by Keyword In the advertisement file, you can assign categories to ads by using the Keyword attribute and then configuring the AdRotator control to show ads according to the filter criteria that you specify. For example, if an ad file contains categories for both banks and hardware stores, you might want the page to display only ads that are related to banks. By setting the AdRotator control's KeywordFilter property to "banks," you can have the control filter out the hardware store ads. If a filter is specified, one of the following two situations can result:
AdRotator control displays a blank image in the browser. Target The Target property specifies the name of the browser window or frame that displays the contents of the Web page linked to when the AdRotator control is clicked. This property can also take the following HTML frame-related keywords. _blank: displays the linked content in a new window without frames _parent: displays the linked content in the parent window of the window that contains the link _self: displays the linked content in the same window _top: displays the linked content in the topmost window
The AdRotator Web server control reads advertisement (ad) information from a data source, which one or more ad records. You can store ad information in an XML file and then bind the AdRotator control to the file.
All attributes of the AdRotator control are optional. The following attributes can be included in the XML files:
ImageUrl
The URL of the image to display. The URL of the page to go to when The text to display if the image is
NavigateUrl
the AdRotator control is clicked. AlternateText Keyword unavailable. The category of the ad, which can be A numeric value (a weighting used to filter for specific ads. Impressions number) that indicates the likelihood of how often the ad is displayed. The total of all impressions values in the XML file cannot exceed 2,048,000,000 - 1.
Height
Width
To create an ad list as an XML file 1. Create a new XML file in your Web site's App_Data folder. For extra security, give the file a file name extension other than .xml, such as .ads. 2. Add the following XML elements to the file:
A sample file might look like the following: <?xml version="1.0" encoding="utf-8" ?> <Advertisements xmlns="http://schemas.microsoft.com/AspNet/AdRotator-Schedule-File"> <Ad> <ImageUrl>~/images/Contoso_ad.gif</ImageUrl> <NavigateUrl>http://www.contoso-ltd.com</NavigateUrl> <AlternateText>Ad for Contoso, Ltd. Web site</AlternateText> <Impressions>100</Impressions> </Ad> <Ad> <ImageUrl>~/images/Aspnet_ad.gif</ImageUrl> <NavigateUrl>http://www.asp.net</NavigateUrl> <AlternateText>Ad for ASP.NET Web site</AlternateText> <Impressions>50</Impressions> </Ad> </Advertisements>
numbers.
tasks when a user clicks an item. Property Description Text Value Specifies the text displayed in the list. Specifies a value that is associated with an item but is not displayed. For example, you can set the Text property to the name of chemical element and the Value property to the symbol of the element. Indicates whether the item is selected. In a CheckBoxList control and in a multi-selection ListBox control, more than one item can be selected. In a DropDownList control, RadioButtonList control, and single-selection ListBox control, only one item can be selected at a time. If you set more than one selected item in these controls, the browser determines which item is rendered as selected. In a BulletedList control, this setting has no effect.
Selected
To add static items at design time 1. In Design view, select the list control to which you want to add items. In the Properties window, click the ellipsis button ( The ListItem Collection Editor dialog box appears. ) in the Items box.
2. Click Add to add a new item. 3. Select the new item, and then in the properties grid,
enter values for its Text, Value, and Selected properties.
4. Repeat steps 2 and 3 for each item you want to add, and
then click OK.
1. Create a new object of type ListItem and set its Text and
Value properties. Typically, you create the new ListItem by calling the Add method.
Calendar
The control
displays a calendar through which users can move to any day in any year. Setting the SelectedDate property causes a specific date to be highlighted in the control. Optionally, users can move to arbitrary dates by clicking a day or moving from month to month. The calendar can be configured to enable users to select multiple dates, either a whole week or a whole month. A representation of the Calendar control displaying the month of October
Notable properties Notable properties of this control that set it's style are as follows: DayHeaderStyle: Sets style for the days of the week DayStyle: Sets styles for the dates in a month NextPrevStyle: Sets style for the navigation controls
OtherMonthStyle: Sets style for the dates that are not in the displayed month SelectedDayStyle: Sets style for the selected date SelectorStyle: Sets style for the for week and month selection column TitleStyle: Sets style for the title TodayDayStyle: Sets style for today's date WeekendDayStyle: Sets style for weekend dates In addition to the properties mentioned above there are some more properties than can be set to control different parts of the calendar. They are as follows: ShowDayHeader: Shows or hides the days of the week ShowGridLines: Shows or hides grid lines ShowNextPrevMonth: Shows or hides the navigation controls to the next or previous month ShowTitle: Shows or hides the title Other properties are as follows:
CellPadding: Gets/Sets the space used for cell padding in the calendar CellSpacing: Gets/Sets the space between cells in the calendar DayNameFormat: Gets/Sets the day of the week's name format FirstDayOfWeek: Gets/Sets the day of the week displayed in the first column NextMonthText: Gets/Sets the text for next month navigation control NextPrevFormat: Gets/Sets the format for the next and previous month navigation controls OtherMonthDayStyle: Gets the style for the days not displyed in current month PrevMonthText: Gets/Sets the text for previous month navigation control SelectedDate: Gets/Sets the selected date SelectedDates: Gets a collection of DateTime objects for the selected dates SelectionMode: Gets/Sets the date selection mode determining if you can select a day, a week, or a month SelectMonthText: Gets/Sets the text for the month selection element SelectWeekText: Gets/Sets the text for week selection element TitleFormat: Gets/Sets the format for the title TodaysDate: Gets/Sets today's date VisibleDate: Gets/Sets a date making sure it's visible
DZONE
Calendar Sample
9829708506
Drag a Calendar and a TextBox control on to the form. The following code will display the date selected from the Calendar control in the TextBox. The code looks like this: Private void Calendar1_SelectionChanged(Object
senderEventArgs e) { TextBox1.Text }
Calendar1.SelectedDate
uploaded.
before storing the file. The FileUpload control enables users to upload pictures, text files, or other files. The FileUpload control displays a text box where users can type the name of a file that they want to upload to the server. The control also displays a Browse button that displays a file-navigation dialog box. (The dialog box that is displayed depends on the operating system of the user's computer.) For security reasons, you cannot pre-load the name of a file into the FileUpload control. Handling Uploaded Files When users have selected a file to upload and then submitted the page, the file is uploaded as part of the request. The file is cached in its entirety in server memory. When the file has finished uploading, your page code runs. You can access the uploaded file in the following ways:
property.
PostedFile
exposes properties, such as the ContentType and ContentLength properties, that provide you with information about the uploaded file. Hidden Field The HiddenField control provides you with a way to store information in the page without displaying it. For example, you might store a user-preference setting in a HiddenField control so that it can be read in client script. To put information into a HiddenField control, you set its Value property to the value you want to store between postbacks The information in a HiddenField control is not displayed when the browser renders the page. However, it can be read and set in client script. When the page is posted back, the contents of the HiddenField control, which includes any changes made in client script, are available in server code.
MultiView and View The MultiView and View Web server controls act as containers for other controls and markup, and provide a way for you to easily present alternate views of information. You can use the MultiView and View controls to perform tasks such as the following:
user choice or other conditions. For example, you might allow users to select from a list of feeds, each of which is configured in a separate View control. You can then display the View control that contains
the user's choice of feeds. You can use the MultiView and View controls as an alternative to creating multiple Panel controls.
Create a multi-page form. The MultiView and Wizard control. The Wizard control is
View controls can provide behavior that is similar to the particularly suited to creating forms that users fill in step by step. The Wizard control also includes support for more built-in UI elements, such as a header and footer, for Previous and Next buttons, and for templates. You might use a MultiView control in place of a Wizard if you wanted to create a display that changed based on condition (rather than sequentially), or if you did not need the extra features supported by the Wizard control. The MultiView control acts as an outer container for one or more View controls. The View controls, in turn, can contain any combination of markup and controls. The MultiView control displays one View control at a time, exposing the markup and controls within that View control. By setting the MultiView control's ActiveViewIndex property, you can specify which View control is currently visible.
Rendering View Control Content If a View control is not selected, it is not rendered to the page. However, instances of all Web server controls in all the View controls are created each time the page is rendered, and their values are stored as part of the page's view state. Neither the MultiView control nor individual View controls render any markup to the page other than the contents of the current View control. For example,
the controls do not render a div element in the same way that a Panel control does. They also do not support appearance properties that can be applied as a whole to the current View control. But you can assign a theme to the MultiView or View controls, which applies the theme to all child controls of the current View control. Panel You can use the Panel control as a container for other controls. This is particularly useful when you are creating content programmatically and you need a way to insert the content into the page. The following sections describe additional ways that you can use the Panel control. Container for Dynamically Generated Controls The Panel control provides a convenient container for controls that you create at run time. Adding Scrollbars to Other Controls Some controls such as the TreeView control do not have built-in scrollbars. You can add scrolling behavior by placing the control in a Panel control. To add scrollbars to the Panel control, set the Height and Width properties to constrain the Panel control to a specific size, and then set the ScrollBars property. Creating areas on the page with a custom color or other appearance The Panel control supports appearance properties such as BackColor and BorderWidth that you can set to create a unique look for a region on a page. To add a Panel control to a Web Forms page
HorizontalAlign Specifies how the child controls are aligned within the panel (left, right, centered, or justified). Wrap Direction Specifies whether content that is too wide for the panel is wrapped to the next line or truncated at the panel's edge. Specifies whether the content of the control renders left-toright or right-to-left. This can be useful for creating areas on the page that have a different direction than the page as a whole. If you have set the Height and Width properties to constrain the Panel control to a specific size, you can add scrollbars by setting the ScrollBars property.
ScrollBars
PlaceHolder The PlaceHolder Web server control lets you place an empty container control within the page and then dynamically add, remove, or loop through child elements at run time. The control renders only its child elements; it renders no markup of its own. In order to programmatically add a control to a page, there must be a container for the new control. For example, if you are creating table rows, the container is the table. If there is no obvious control to act as container, you can use a PlaceHolder or Panel Web server control. In some instances, you might want to create both static text and controls. To create static text, you can use either a Literal or a Label Web server control. You can then add these controls to the container as you would any other control.
In order to programmatically add a control to a page, there must be a container for the new control. For example, if you are creating table rows, the container is the table. If there is no obvious control to act as container, you can use a PlaceHolder or Panel Web server control. In some instances, you might want to create both static text and controls. To create static text, you can use either a Literal or a Label Web server control. You can then add these controls to the container as you would any other control.
Label myLabel = new Label(); // Set the label's Text and ID properties. myLabel.Text = "Welcome" ; myLabel.ID = "Label1" ; PlaceHolder1.Controls.Add(myLabel); RadioButton and RadioButtonList You can use two types of Web server controls to add radio buttons to an ASP.NET Web page: individual RadioButton controls or a RadioButtonList control. Both controls enable users to select from a small set of mutually exclusive, predefined choices. The controls enable you to define any number of radio buttons with labels and to arrange them horizontally or vertically. You add individual RadioButton controls to a page and work with them singly. Typically, you group two or more individual buttons together. Alternatively, you can use the RadioButtonList control, which is a single control that acts as a parent control for a collection of radio button list items. It derives from the base ListControl class. Therefore, it works much like the ListBox, DropDownList, BulletedList, and CheckBoxList Web server controls. Many of the procedures for working with the RadioButtonList control are the same as they are for the other list Web server controls. The RadioButtonList control is a better choice if you want to create a group of radio buttons based on data in a data source. It is also slightly easier to write code that determines which button has been selected.
Grouping Radio Buttons Radio buttons are rarely used singly. Instead, they are grouped to provide a set of mutually exclusive options. Within a group, only one radio button can be selected at a time. You can create grouped radio buttons in these ways:
Add
individual
RadioButton
Web
server
controls to a page and then manually assign them all to a group. The group name is arbitrary; all radio buttons with the same group name are considered part of a single group.
the page. The list items in the control are automatically grouped.
XML Control An Xml Web server control reads XML and writes it into an ASP.NET Web page at the location of the control. If an XSL transformation (XSLT) is applied to the XML, the resulting transformed output will be rendered in the page. You can use the XML Web server control to write an XML document, or the results of an XSLT transformation, into an ASP.ENT Web page. The XML output appears in the Web page at the location of the control. To provide a path to an external XML document
1. Add an Xml control to the Web Forms page. 2. Set the DocumentSource property of the control to the
path to the XML source document. Table The Table Web server control allows us to build an HTML table and helps us organize data in a tabular form. Tables can be created at design time or run time. To create a table we also need the TableRow and TableCell web controls. If you create a table at design time you often fill it's contents with
static data but if you create it at run time then you can fill it with dynamic content like binding it to a data source. The class hierarchy for this control is as follows: Object Control WebControl Table Notable Properties Notable properties of the Table control are as follows:
CellPadding: Gets/Sets the distance between the border and the contents of the table cell CellSpacing: Gets/Sets the distance between table cells GridLines: Gets/Sets the gridline property of the table class HorizontalAlign: Gets/Sets the horizontal alignment of the table within the page Rows: Gets/Sets the collection of rows within the table TableRow Control The TableRow class is used to create the table rows we use in the Table control. It controls how the contents of the table are displayed. The class hierarchy for this control is as follows: Object Control WebControl TableRow Notable Properties Notable properties of the TableRow class are as follows:
Cells: Gets a collection of the table cells for the table row HorizontalAlign: Gets/Sets the horizontal alignment of the row contents VerticalAlign: Gets/Sets the vertical alignment of the row contents
TableCell Control The TableCell class represents a cell in the Table contol. We use the Text property to set the contents of the cell. The class hierarchy for this control is as follows:
Object Control WebControl TableCell Notable Properties Notable proeprties of the TableCell class are as follows:
ColumnSpan: Gets/Sets the number of columns the cell spans HorizontalAlign: Gets/Sets the cell content's horizontal alignment RowSpan: Gets/Sets the number of rows the cell spans Text: Gets/Sets the text in the cell VerticalAlign: Gets/Sets the cell content's vertical alignment Wrap: Gets/Sets whether the cell content wraps Creating Tables Creating a table at design time is fairly simple. Drag a table control on to the form and add some rows and columns to it using the Rows property. When you click the ellipse button in the Rows property it opens the TableRow Collection Editor window as shown in the image below. You need to click the Add button found on this dialog to add rows to the table. Once you add a row to the table you can notice the properties for the newly added row in the right column of the TableRow Collection Editor window. You can set properties for the row in this column. To add a cell to a row, select the row and click the ellipse button found in the Cells property to open the TableCell Collection Editor Window. You need to click the Add button found on this window to add cells to the row. Once you add a cell to the row you can notice the properties of the newly added row in the right column of the TableCell Collection Editor window. You can add any number of cells to a row depending upon your requirements. You can view a table at work below.
Validation Controls Validation is the process of making sure that the user enters correct information into a form. Validation controls provided by .NET Framework work in the client browser if the browser supports Javascript and DHTML and checks the data the user entered before sending it to the server. All the validation takes place in the browser and nothing is sent back to the server. If the browser doesn't support DHTML and scripting then validation is done on the server. All validation controls in the .NET Framework are derived from the BaseValidator class. This class serves as the base abstract class for the
validation controls and provides the implementation for all validation controls that derive from this class. The validation controls that are provided by the .NET Framework are as follows: RequiredFieldValidator CompareValidator RangeValidator RegularExpressionValidator CustomValidator Common to all the above said controls are the ErrorMessage and ControlToValidate properties. The ErrorMessage property is used to set an error to be displayed and the ControlToValidate property is used to set the control you want to check. RequiredFieldValidator Simplest of all, the RequiredField validator makes sure that the user enters data into a form. For example, on a registration form you might want your users to enter their date of birth in a textbox. If they leave this field empty, this validation control will display an error. The class hierarchy for this control is as follows: Object Control WebControl Label BaseValidator RequiredFieldValidator Notable property of the RequiredFieldValidator is the InitialValue property which sets an initial value in the control. CompareValidator Comparison validators are used to compare the values entered by the user into a control (textbox) with the value entered into another control or with a constant value. We indicate the control to validate by setting the ControlToValidate property and if we want to compare a specific control with another control we need to set the ControlToCompare property to specify the control to compare with. The class hierarchy for this control is as follows: Object Control WebControl Label
BaseValidator BaseCompareValidator CompareValidator RangeValidator Range Validators are used to test if the value of a control is inside a specified range of values. The three main properties of this control are the ControlToValidate property which contains the control to validate and Maximum and Minimum values which hold the maximum and minimum values of the valid range. The class hierarchy for this control is as follows: Object Control WebControl Label BaseValidator BaseCompareValidator RangeValidator RegularExpressionValidator RegularExpression validators are used to check if the value in a control matches a pattern defined by the regular expression. Notable property for this control is the ValidationExpression property which allows us to select a predefined expression which we want to match with the data entered in a control. The class hierarchy for this control is as follows: Object Control WebControl Label BaseValidator RegularExpressionValidator CustomValidator Custom validators are used to perform our own validation for the data in a control. For example, you can check the value entered by a user is even or odd with this control which is not possible with any of the above mentioned validation controls. You write the script for the validation using Javascript or VBScript and associate that script function to the ClientValidationFunction property of this control. The class hierarchy for this control is as follows: ValidationSummary Validation summary control is used to display a summary of all validation errors (from all validation controls) on a Web page. This class is supported by
the
ValidationSummary
class
and
the
hierarchy
is
as
follows:
Object Control WebControl ValidationSummary Notable property of this control is the DisplayMode property which allows us to display the errors in a specific format, example, as a list, paragraph or as a bulletlist.
ADO .NET
Most applications need data access at one point of time making it a crucial component when working with applications. Data access is making the application interact with a database, where all the data is stored. Different applications have different requirements for database access. ASP.NET uses ADO .NET (Active X Data Object) as it's data access and manipulation protocol which also enables us to work with data on the Internet. ADO.NET Data Architecture Data Access in ADO.NET relies on two components: DataSet and Data Provider. DataSet The dataset is a disconnected, in-memory representation of data. It can be considered as a local copy of the relevant portions of the database. The DataSet is persisted in memory and the data in it can be manipulated and updated independent of the database. When the use of this DataSet is finished, changes can be made back to the central database for updating. The data in DataSet can be loaded from any valid data source like Microsoft SQL server database, an Oracle database or from a Microsoft Access database. Data Provider The Data Provider is responsible for providing and maintaining the connection to the database. A DataProvider is a set of related components that work together to provide data in an efficient and performance driven manner. The .NET Framework currently comes with two DataProviders: the SQL Data Provider which is designed only to work with Microsoft's SQL Server 7.0 or later and the OleDb DataProvider which allows us to connect to other types of databases like Access and Oracle. Each DataProvider consists of the following component classes:
The Connection object which provides a connection to the database The Command object which is used to execute a command The DataReader object which provides a forward-only, read only, connected recordset The DataAdapter object which populates a disconnected DataSet with data and performs update
Data access with ADO.NET can be summarized as follows: A connection object establishes the connection for the application with the database. The command object provides direct execution of the command to the database. If the command returns more than a single value, the command object returns a DataReader to provide the data. Alternatively, the DataAdapter can be used to fill the Dataset object. The database can be updated using the command object or the DataAdapter.
DZONE
9829708506
Component classes that make up the Data Providers The Connection Object The Connection object creates the connection to the database. Microsoft Visual Studio .NET provides two types of Connection classes: the SqlConnection object, which is designed specifically to connect to Microsoft SQL Server 7.0 or later, and the OleDbConnection object, which can provide connections to a wide range of database types like Microsoft Access and
Oracle. The Connection object contains all of the information required to open a connection to the database. The Command Object The Command object is represented by two corresponding classes: SqlCommand and OleDbCommand. Command objects are used to execute commands to a database across a data connection. The Command objects can be used to execute stored procedures on the database, SQL commands, or return complete tables directly. Command objects provide three methods that are used to execute commands on the database: ExecuteNonQuery: Executes commands that have no return values such as INSERT, UPDATE or DELETE ExecuteScalar: Returns a single value from a database query ExecuteReader: Returns a result set by way of a DataReader object The DataReader Object The DataReader object provides a forward-only, read-only, connected stream recordset from a database. Unlike other components of the Data Provider, DataReader objects cannot be directly instantiated. Rather, the DataReader is returned as the result of the Command object's ExecuteReader method. The SqlCommand.ExecuteReader method returns a SqlDataReader object, and the OleDbCommand.ExecuteReader method returns an OleDbDataReader object. The DataReader can provide rows of data directly to application logic when you do not need to keep the data cached in memory. Because only one row is in memory at a time, the DataReader provides the lowest overhead in terms of system performance but requires the exclusive use of an open Connection object for the lifetime of the DataReader. The DataAdapter Object The DataAdapter is the class at the core of ADO .NET's disconnected data access. It is essentially the middleman facilitating all communication between the database and a DataSet. The DataAdapter is used either to fill a DataTable or DataSet with data from the database with it's Fill method. After the memory-resident data has been manipulated, the DataAdapter can commit the changes to the database by calling the Update method. The DataAdapter provides four properties that represent database commands: SelectCommand InsertCommand DeleteCommand UpdateCommand
When the Update method is called, changes in the DataSet are copied back to the database and the appropriate InsertCommand, DeleteCommand, or UpdateCommand is executed.
Framework Concepts
Assemblies Assembly is a single deployable unit that contains information about the implementation of classes, structures and interfaces. it also stores the information about itself called metadata and includes name and verison of the assembly, security information, information about the dependencies and the list of files that constitute the assembly. Assembly Logical unit of deployment Contains Manifest, Metadata, MSIL and resources Manifest Metadata about the components in an assembly (version, types, dependencies, etc.) Type Metadata Completely describes all types defined in an assembly: properties, methods, arguments, return values, attributes, base classes, Microsoft Intermediate Language (MSIL, IL) All languages compile to IL (managed code) IL is always compiled to native being executed
code
before
thread
Code management Conversion of MSIL to native code Loading and execution of managed code Creation and management of metadata Verification of type safety Insertion and execution of security checks Memory management and isolation
Handling exceptions across languages Interoperation between .NET Framework objects and COM objects and Win32 DLLs
Automation of object layout for late binding Developer services debugging, etc.) (profiling,
Runtime
MSIL
Ngen
Assembly
Native code
CLR Code
Managed
Managed Code
Managed Code
Unmanaged Code
CLR Services
Operating System Services Multiple Language Support : Common Type System (CTS) A superset of the data types used by most modern programming languages Common Language Specification (CLS) A subset of CTS that allows code written in different languages to interoperate
Order of Page events Cycle i. ii. iii. iv. v. vi. vii. viii. ix. x. xii. level Page_Init Page_LoadViewState Page_LoadPostData Page_Load Page_RaisePostDataChanged Page_RaisePostBackEvent Page_PreRender Page_SaveViewState Page_Render Page_Dispose Page_Error (this is caused whenever there is an exception at the page
The Managed Heap Reduces bugs Makes code access security possible No direct memory access Makes type safety possible Incompatible type coercion not possible Performance Newing up objects is much faster than malloc() Garbage Collection Garbage collection occurs when a new operation fails due to lack of memory All managed threads are stopped
Serialization Serialization is the process of converting an object, or a connected graph of objects, stored within computer memory, into a linear sequence of bytes Boxing and unboxing ?
Boxing: The conversion of a value type instance to an object, which implies that the instance will carry full type information at run time and will be allocated in the heap. Un-Boxing: The conversion of an object instance to a value type.
Reference type and value type Data Reference Type: Reference types are allocated on the managed CLR heap, just like object types. A data type that is stored as a reference to the values location. The value of a reference type is the location of the sequence of bits that represent the types data. Reference types can be self-describing types, pointer types, or interface types Value Type: Value types are allocated on the stack just like primitive types in VBScript, VB6 and C/C++. Value types are not instantiated using new go out of scope when the function they are defined within returns.Value types in the CLR are defined as types that derive from system.valueType. A data type that fully describes a value by specifying the sequence of bits that constitutes the values representation. Type information for a value type instance is not stored with the instance at run time, but it is available in metadata. Value type instances can be treated as objects using boxing.
Difference between an EXE and a DLL? You can create an objects of Dll but not of the EXE. Dll is an In-Process Component whereas EXE is an OUt-Process Component. Exe is for single use whereas you can use Dll for multiple use. Exe can be started as standalone where dll cannot be. What is MSIL?.
When compiling to managed code, the compiler translates your source code into Microsoft intermediate language (MSIL), which is a CPU-independent set of instructions that can be efficiently converted to native code. MSIL includes instructions for loading, storing, initializing, and calling methods on objects, as well as instructions for arithmetic and logical operations, control flow, direct memory access, exception handling, and other operations. Before code can be run, MSIL must be converted to CPU-specific code, usually by a justin-time (JIT) compiler. Because the common language runtime supplies one or more JIT compilers for each computer architecture it supports, the same set of MSIL can be JIT-compiled and run on any supported architecture. When a compiler produces MSIL, it also produces metadata. Metadata describes the types in your code, including the definition of each type, the signatures of each types members, the members that your code references, and other data that the runtime uses at execution time. The MSIL and metadata are contained in a portable executable (PE) file that is based on and extends the published Microsoft PE and common object file format (COFF) used historically for executable content. This file format, which accommodates MSIL or native code as well as metadata, enables the operating system to recognize common language runtime images. The presence of metadata in the file along with the MSIL enables your code to describe itself, which means that there is no need for type libraries or Interface Definition Language (IDL). The runtime locates and extracts the metadata from the file as needed during execution.
What is managed and unmanaged code? The .NET framework provides several core run-time services to the programs that run within it - for example exception handling and security. For these services to work, the code must provide a minimum level of information to the runtime. i.e., code executing under the control of the CLR is called managed code. For example, any code written in C# or Visual Basic .NET is managed code. Code that runs outside the CLR is referred to as unmanaged code. COM components, ActiveX components, and Win32 API functions are examples of unmanaged code. Different b/w webconfig.xml & Machineconfig.xml Web.config & machine.config both are configuration files.Web.config contains settings specific to an application where as machine.config contains settings to a computer. The Configuration system first searches settings in
DZONE
9829708506
machine.config file & then looks in application configuration files.Web.config, can appear in multiple directories on an ASP.NET Web application server. Each Web.config file applies configuration settings to its own directory and all child directories below it. There is only Machine.config file on a web server.
How is meant by DLL ? A DLL (Dynamic Link Library) is a file that can be loaded and executed by programs dynamically. Basically its an external code repository for programs. Since usually several different programs reuse the same DLL instead of having that code in their own file, this dramatically reduces required storage space. A synonym for a DLL would be library Difference between user control an custom control? Web user controls Vs Web custom controls Easier to create Vs Harder to create Limited support for consumers who use a visual design tool Vs Full visual design tool support for consumers A separate copy of the control is required in each application Vs Only a single copy of the control is required, in the global assembly cache Cannot be added to the Toolbox in Visual Studio Vs Can be added to the Toolbox in Visual Studio Good for static layout Vs Good for dynamic layout.
format,it can be readily communicated across HTTP and providinga simple method to transmit structured data across firewalls. Disconnected data access ADO use connection-oriented approach for accessing data while ADO .NET use dataset in disconnected mode.It is useful in n-tier environment where maintaining open connection to the database are typically inefficient and ineffective. COM marshaling versus text-based data transmission In ADO data transmission of disconnected recordset can occcured only between the components which support COM. With ADO .NET the native support of XML overcome this issue and provides an approach for transmission of any data type between almost any plateform. Varient versus strongly typed data Ado use varient data type while ADO .NET utilized strongly typed data which ensures that conversion of data from one type to another is accurate and complete.
DataSet Feature
A DataSet can represent an entire relational database in memory, complete with tables, relations, and views. A DataSet is designed to work without any continuing connection to the original data source. Data in a DataSet is bulk-loaded, rather than being loaded on demand. There's no concept of cursor types in a DataSet. DataSets have no current record pointer You can use For Each loops to move through the data. You can store many edits in a DataSet, and write them to the original data source in a single operation.
Because the dataset can hold multiple, separate tables and maintain information about relationships between them, it can hold much richer data structures than a recordset, including self-relating tables and tables with many-to-many relationships.
Sessions
When a session is initiated on first request, the server issues a unique session ID to the user. To persist the session ID, store it in an in-memory cookie (which is the default), or embed it within the request URL after the application name. To switch between cookie and cookieless session state, set the value of the cookieless parameter in the Web.config file to true or false.
In cookieless mode, the server automatically inserts the session ID in the relative URLs only. ASP.NET supports three modes of session state: InProc: In-Proc mode stores values in the memory of the ASP.NET worker process. Thus, this mode offers the fastest access to these values. However, when the ASP.NET worker process recycles, the state data is lost. StateServer: Alternately, StateServer mode uses a standalone Microsoft Windows service to store session variables. Because this service is independent of Microsoft Internet Information Server (IIS), it can run on a separate server. You can use this mode for a load-balancing solution because multiple Web servers can share session variables. Although session variables are not lost if you restart IIS, performance is impacted when you cross process boundaries. SqlServer: If you are greatly concerned about the persistence of session information, you can use SqlServer mode to leverage Microsoft SQL Server to ensure the highest level of reliability. SqlServer mode is similar to out-of-process mode, except that the session data is maintained in a SQL Server. SqlServer mode also enables you to utilize a state store that is located out of the IIS process and that can be located on the local computer or a remote server.
Cookies
A cookie is a small bit of text that accompanies requests and pages as they go between the Web server and browser. The cookie contains information the Web application can read whenever the user visits the site. For example, if a user requests a page from your site and your application sends not just a page, but also a cookie containing the date and time, when the user's browser gets the page, the browser also gets the cookie, which it stores in a folder on the user's hard disk. Later, if user requests a page from your site again, when the user enters the URL the browser looks on the local hard disk for a cookie associated with the URL. If the cookie exists, the browser sends the cookie to your site along with the page request. Your application can then determine the date and
time that the user last visited the site. You might use the information to display a message to the user or check an expiration date. Cookies are associated with a Web site, not with a specific page, so the browser and server will exchange cookie information no matter what page the user requests from your site. As the user visits different sites, each site might send a cookie to the user's browser as well; the browser stores all the cookies separately. Cookies help Web sites store information about visitors. More generally, cookies are one way of maintaining continuity in a Web applicationthat is, of performing state management. Except for the brief time when they are actually exchanging information, the browser and Web server are disconnected. Each request a user makes to a Web server is treated independently of any other request. Many times, however, it's useful for the Web server to recognize users when they request a page. For example, the Web server on a shopping site keeps track of individual shoppers so the site can manage shopping carts and other user-specific information. A cookie therefore acts as a kind of calling card, presenting pertinent identification that helps an application know how to proceed. Cookies are used for many purposes, all relating to helping the Web site remember users. For example, a site conducting a poll might use a cookie simply as a Boolean value to indicate whether a user's browser has already participated in voting so that the user cannot vote twice. A site that asks a user to log on might use a cookie to record that the user already logged on so that the user does not have to keep entering credentials. Cookies provide a means in Web applications to store user-specific information. For example, when a user visits your site, you can use cookies to store user preferences or other information. When the user visits your Web site another time, the application can retrieve the information it stored earlier. Browsers also impose limitations on how many cookies your site can store on the user's computer. Most browsers allow only 20 cookies per site; if you try
to store more, the oldest cookies are discarded. Some browsers also put an absolute limit, usually 300, on the number of cookies they will accept from all sites combined. A cookie limitation that you might encounter is that users can set their browser to refuse cookies.
Web Services
Web Services can convert your applications into Web-applications. By using Web services, your application can publish its function or message to the rest of the world. Web Services can be used by other applications. With Web services your accounting department's Win 2k servers can connect with your IT supplier's UNIX server. The basic Web Services platform is XML + HTTP. Web services uses XML to code and decode your data and SOAP to transport it. What are Web Services?
Web services are application components Web services communicate using open protocols Web services are self-contained and self-describing Web services can be discovered using UDDI Web services can be used by other applications XML is the basis for Web services
How Does it Work? The basic Web services platform is XML + HTTP. The HTTP protocol is the most used Internet protocol. XML provides a language which can be used between different platforms and programming languages and still express complex messages and functions. WSDL
WSDL is an XML-based language for describing Web services and how to access them. WSDL describes a web service, along with the message format and protocol details for the web service. If you want to learn more about WSDL, please visit our WSDL tutorial. SOAP SOAP is a simple XML-based protocol that allows applications to exchange information over HTTP. Or more simply: SOAP is a protocol for accessing a web service. What is SOAP?
SOAP stands for Simple Object Access Protocol SOAP is a communication protocol SOAP is for communication between applications SOAP is a format for sending messages SOAP is designed to communicate via Internet SOAP is platform independent SOAP is language independent SOAP is based on XML SOAP is simple and extensible SOAP allows you to get around firewalls SOAP will be developed as a W3C standard
Why SOAP? It is important for application development to allow Internet communication between programs. Today's applications communicate using Remote Procedure Calls (RPC) between objects like DCOM and CORBA, but HTTP was not designed for this. RPC represents a compatibility and security problem; firewalls and proxy servers will normally block this kind of traffic. A better way to communicate between applications is over HTTP, because HTTP is supported by all Internet browsers and servers. SOAP was created to accomplish this.
SOAP provides a way to communicate between applications running on different operating systems, with different technologies and programming languages. Web Services basically uses Hypertext Transfer Protocol (HTTP) and SOAP to make business data available on the Web. It exposes the business objects (COM objects, Java Beans, etc.) to SOAP calls over HTTP and executes remote function calls. The Web Service consumers are able to invoke method calls on remote objects by using SOAP and HTTP over the Web.
Figure 1. SOAP calls are remote function calls that invoke method executions on Web Service components at Location B. The output is rendered as XML and passed back to the user at Location A. How is the user at Location A aware of the semantics of the Web Service at Location B? This question is answered by conforming to a common standard. Service Description Language (SDL), SOAP Contract Language (SCL) and Network Accessible Specification Language (NASSL) are some XML-like languages built for this purpose. However, IBM and Microsoft recently agreed on the Web Service Description Language (WSDL) as the Web Service standard.