This action might not be possible to undo. Are you sure you want to continue?
• Web Server Connections.
Assignment No: 01
Ans. Web Applications: A collection of elements that make up a web site or distinct portion of a web site organized under a virtual root. Web applications are built from web projects. A web project can reference a single web application. Each web application requires a combination of hardware and software pieces that are needed for developing a web application that incorporates a database. Web server connection: The detailed interaction of the components depends on the mode of your project. The following section shows the difference between the interaction of system components for designing and testing in local and master modes. Typically the system components interact using HTTP, except for the database components which are likely to use a Local Area Network (LAN) connection or Wide Area Network (WAN). The web software with the master web server via HTTP. Communicating via HTTP allows us to develop web applications in a distributed environment where the master web server and local development machine might only be connected via the internet. 2. Write a sample program using ASP.NET explaining all the syntax and semantics of the program. Ans. <b><%@ Page Language="VB" %></b> <html> <b><script runat="server"></b> <b> Sub Button1_Click(ByVal sender As Object, _</b> <b> ByVal e As System.EventArgs)</b> <b> Label1.Text = "Welcome, " & TextBox1.Text</b> <b> End Sub</b> <b></script></b> <head <b>runat="server"</b>> <title>Basic ASP.NET Web Page</title> </head> <body> <form id="form1" <b>runat="server"</b>> <h1>Welcome to ASP.NET</h1> <p>Type your name and click the button.</p> <p> <b><asp:TextBox ID="TextBox1" runat="server"></asp:TextBox></b> <b><asp:Button ID="Button1" runat="server" </b> <b>Text="Click" OnClick="Button1_Click" /></b> </p> <p> <b><asp:Label ID="Label1" runat="server"></asp:Label></b> </p> </form> </body> </html>
3. Explain with the help of sample program the validation concept of input controls in ASP.NET Application. Ans. The Validation Application Block contains a wide range of validators that you can use to check almost any type of property or value. The built-in validators include:
Range Validators o Range Validator - checks that a value falls within a specified range. The range may be either closed, which means it has both a lower and an upper bound specified, or open, which means that it only has one bound specified. The Range Validator can be used with any type that implements the IComparable interface. This includes all numeric types and strings. While it is possible, in code, to use this validator with DateTime types, the Date Time Range Validator may be a better choice because it allows you to take advantage of attributes and configuration. o Date Time Range Validator - checks that a DateTime object falls within the specified range. o String Length Validator - checks that the length of the string is within the specified range. The range may include or exclude the endpoints by omitting the lower or upper bound. String Validators o Contains Characters Validator - checks that an arbitrary string, such as a string entered by a user in a Web form, contains any or all of the characters that are specified by the CharacterSet property. o Regular Expression Validator - checks that the value matches the pattern specified by a regular expression. o Type Conversion Validator - checks that a string can be converted to a specific type. For example, the validator can check that "6.32" can be converted to a Double type or that "2007-02-09" can be converted to a DateTime type. Set Validators o Domain Validator - checks that a value is one of the specified values in a specified set. For example, it can check that a name is "Tom," "Dick," "Harry," or "George" or that an integer is 2, 3, 5, 7, or 11. If the set only contains one value, you can use this validator to check for equality. o Enum Conversion Validator - checks that a string can be converted to a value in a specified enum type. For example, it can check that "Blue" can be converted to a value in the Color enumeration. Comparison Validators o Property Comparison Validator - compares the value to be checked with the value of a property. For example, a n AuctionItem object, the current bid is greater than or equal to the minimum bid. o Relative Date Time Validator - checks that the DateTime value falls within a specified range using relative times and dates. Object Validators o Not Null Validator - checks that the value is not null. o Object Validator - causes validation to occur on an object reference. All validators defined for the object's type will be invoked, just as if the Validation.Validate method had been called on the object. If the object you want to validate is null, the validation is ignored. If the reference is to an instance of a type that is not compatible with the configured target's type, the validation fails. This validator is helpful for validating tree-structured data. o Object Collection Validator - checks that the object is a collection of the specified type and then invokes validation on each element of the collection. If the object you
want to validate is null, the validation is ignored. If the object you want to validate is not a collection, then the validation fails and the rule set is not applied. If there are elements in the collection that are of a different type than the one you specified for the object, then the validation for these elements fails but this does not affect validation for the other elements. The Validation Application Block also provides the following composite validators which allow you to combine other validators by nesting them within this type of validator to create complex validation rules.
And Composite Validator - requires that all the validators that make up the composite validator be true. For example, you can use the And Composite Validator to require that the Not Null Validator AND the Date Time Range Validator be True. Because the Validation Application Block's default behavior is to AND validators, you only need this validator to implement complex logic. Or Composite Validator - requires that at least one of the validators that make up the composite validator be True. For example, you can use the Or Composite Validator to require that the Not Null Validator OR the Date Time Range Validator be True.
Each validator also has a Negated property, which reverses the operation of the validator so that it returns False if the value is valid, and True if not. This is useful when you combine validators using the And Composite Validator and the Or Composite Validator. 4. Demonstrate the concept of possible Validation Errors with a suitable example using a ASP.NET application. Ans. If a validation control is in error, an error message may be displayed in the page by that validation control or in a validationsummary control elsewhere on the page. The validationsummary control is displayed when the isvalid property of the page is false. The following example illustrates displaying errors with a validationsummary control. Example: <htme> <head> <script language=”VB” runat=”server”> Sub listformat_selectedindexchanged(sender as object, e as eventargs) Valsum.displaymode=listformat.selectedindex End sub </script> </heat> <body> <h3><font face=”arial”> validation summary sample</font></h3> <p> <form runat=”server”> <table cellpadding=10> <tr> <td> <table bgcolor=”yellow” cellpadding=10> <tr> <td colspan=3> <font face=arial black size=3><b> credit card information</b></font> </td> </tr>
Introduction to .NET Technologies
Assignment No: 02
1. Discuss the basics of ASP.NET along with the steps required to compile and execute an ASP.NET program. Ans. ASP.NET offers a novel programming model and infrastructure that facilitates a powerful new class of applications. ASP.NET is a compiled Net base environment, so one can author applications in any .NET compatible language, including Visual Basic, c# and Jscript.NET. Developers can effortlessly access the advantage of these technologies, which consist of a managed common language environment, type safety, inheritance, and son on. With the aid of Microsoft Visual Basic.NET Web development becomes easier. When an ASP.NET page is first requested, it is compiled and cached on the server. This means that an ASP.NET page performs very rapidly. All ASP.NET code is compiled rather than interpreted, which permits early binding, strong typing, and just-in-time compiling to native code. 2. Explain with the help of a program the ASP.NET Server controls.
Ans. ASP.NET server controls: In addition to using <% %> code blocks to program dynamic content, ASP.NET page developers can use ASP.NET server controls to the program web pages. Server controls are declared within an .aspx file using custom tags or intrinsic HTML tags that contain a runat=”server” attributes value. Intrinsic HTML tags are handled by one of the controls in the System.web.UI.HtmlControls namespace. Any tag that doesn’t explicitly map to one of the controls is assigned the type of System.web.UI.HtmlControls.HtmlGenericControl. 3. Explain with the help of sample program the concept of Client Side validation in ASP.NET. Ans. The validation controls always perform validation checking in server code. However, if the user is working with a browser that supports DHTML, the validation controls can also perform validation using client script. With client- side validation, any errors are detected on the client when the form is submitted to the server. If any of the validators are found to be in error, the submission of the form to the server is cancelled and the validator’s Text property is displayed. This permits the user to correct the input before submitting the form to the server. Field values are revalidated as soon as the field containing the error loses focus, thus providing the user with a rich, interactive validation experience. 4. Discuss the following Database Handling concepts of ASP.NET: • Server Side Data. • Accessing SQL based data.
Ans. Server -Side Data: Data access is the heart of any real- world application, and ASP.NET provides a rich set of controls that are well- integrated with the managed data access APIs provided in the common language runtime. Server- side data access is unique in that web pages are basically stateless, which presents some difficult challenges when trying to perform transactions such as inserting or updating records from a set of data retrieved from a database. The DataGrid control help to manage these challenges, allowing to concentrate more on application logic and less on the details of state management and event handling.
Accessing SQL based data: An application typically needs to perform one or more select, insert, update, or delete queries to a SQL database. The following table shows an example of each of these queries: Query Simple Select Join Select Insert Update Delete Example SELECT * from Employees WHERE FirstName=’Bradley’; SELECT * from Employees V¡xzsth, Managers M WHERE E.FirstName=M.FirstName; INSERT into Employees VALUES (‘123-45-6789’,’Bradley’,’Program Manager’); UPDATE Employees SET Title=’Development Lead’ WHERE FirstName=’Bradley’; DELETE from Employees WHERE Productivity < 10;
To give our page access to the classes you will need to perform SQL data access, we must import the System.Data and System.Data.SqlClient namespaces into our page. <%@ Import Namespace=”System.Data”%> <%@ Import Namespace=”System.Data.SqlClient”%> To perform a select query to a SQL database, we create a SqlConnection to the database passing the connection string, and then construct a SqlDataAdapter object that contains our query statement. To populate a Dataset object with the results from the query, we call the command’s Fill method.
5. Explain the steps in debugging an ASP.NET Application with a programming example. Ans. ASP.NET web service implementations rely on the ASP.NET run time to dynamically compile the web service at run time. To generate the symbolic debugging information required to debug a web service, we need to instruct the ASP.NET runtime to compile the application. To configure a web service to be compiled with symbols, we must include a debug attribute in the <compilation> section of the web.config file. The .NET debugger represents a breakpoint using a red circle in the code margin adjacent to the appropriate line of code. We can toggle the breakpoint on and off by clicking in the code margin repeatedly.
This action might not be possible to undo. Are you sure you want to continue?
We've moved you to where you read on your other device.
Get the full title to continue reading from where you left off, or restart the preview.