Qus: What is a user control?
Ans: An ASP.NET user control is a group of one or more server controls or static HTML elements that encapsulate a piece of functionality. A user control could simply be an extension of the functionality of an existing server control(s) (such as an image control that can be rotated or a calendar control that stores the date in a text box). Or, it could consist of several elements that work and interact together to get a job done (such as several controls grouped together that gather information about a user's previous work experience).
Qus: What are different types of controls available in ASP.net?
Ans:
- HTML server controls HTML elements exposed to the server so you can program them. HTML server controls expose an object model that maps very closely to the HTML elements that they render.
- Web server controls Controls with more built-in features than HTML server controls. Web server controls include not only form-type controls such as buttons and text boxes, but also special-purpose controls such as a calendar. Web server controls are more abstract than HTML server controls in that their object model does not necessarily reflect HTML syntax.
- Validation controls Controls that incorporate logic to allow you to test a user's input. You attach a validation control to an input control to test what the user enters for that input control. Validation controls are provided to allow you to check for a required field, to test against a specific value or pattern of characters, to verify that a value lies within a range, and so on.
- User controls Controls that you create as Web Forms pages. You can embed Web Forms user controls in other Web Forms pages, which is an easy way to create menus, toolbars, and other reusable elements.
- Note You can also create output for mobile devices. To do so, you use the same ASP.NET page framework, but you create Mobile Web Forms instead of Web Forms pages and use controls specifically designed for mobile devices.
Qus: What are the validation controls available in ASP.net?
Ans: Type of validation Control to use
Required entry Required Field Validator Ensures that the user does not skip an entry.
Comparison to a value Compare Validator Compares a user's entry against a constant value, or against a property value of another control, using a comparison operator (less than, equal, greater than, and so on).
Range checking Range Validator Checks that a user's entry is between specified lower and upper boundaries. You can check ranges within pairs of numbers, alphabetic characters, and dates.
Pattern matching Regular Expression Validator Checks that the entry matches a pattern defined by a regular expression. This type of validation allows you to check for predictable sequences of characters, such as those in social security numbers, e-mail addresses, telephone numbers, postal codes, and so on.
User-defined Custom Validator Checks the user's entry using validation logic that you write yourself. This type of validation allows you to check for values derived at run time.
Qus: How will you upload a file to IIS in Asp and how will you do the same in ASP.net?
Ans: First of all, we need a HTML server control to allow the user to select the file. This is nothing but the same old <input tag, with the type set to File, such as <input type=file id=â€myFile†runat=server >. This will give you the textbox and a browse button. Once you have this, the user can select any file from their computer (or even from a network). Then, in the Server side, we need the following line to save the file to the Web Server.
myFile.PostedFile.SaveAs ("DestinationPath")
Note: The Form should have the following ENC Type
<form enctype="multipart/form-data" runat="server">
Qus: What is Attribute Programming? What are attributes? Where are they used?
Ans:Attributes are a mechanism for adding metadata, such as compiler instructions and other data about your data, methods, and classes, to the program itself. Attributes are inserted into the metadata and are visible through ILDasm and other metadata-reading tools. Attributes can be used to identify or use the data at runtime execution using .NET Reflection.
Qus: What is the difference between Data Reader & Dataset?
Ans:Data Reader is connected, read only forward only record set.
Dataset is in memory database that can store multiple tables, relations and constraints; moreover dataset is disconnected and is not aware of the data source.
Qus: What is the difference between server side and client side code?
Ans:Server code is executed on the web server where as the client code is executed on the browser machine.
Qus: Why would you use “Enable View
State†property? What are the disadvantages?
Ans: Enable View State allows me to retain the values of the controls properties across the requests in the same session. It hampers the performance of the application.
Qus: What is the difference between Server. Transfer and Response. Redirect?
Ans:The Transfer method allows you to transfer from inside one ASP page to another ASP page. All of the state information that has been created for the first (calling) ASP page will be transferred to the second (called) ASP page. This transferred information includes all objects and variables that have been given a value in an Application or Session scope, and all items in the Request collections. For example, the second ASP page will have the same SessionID as the first ASP page.When the second (called) ASP page completes its tasks, you do not return to the first (calling) ASP page. All these happen on the server side browser is not aware of this.
The redirect message issue HTTP 304 to the browser and causes browser to got the specified page. Hence there is round trip between client and server. Unlike transfer, redirect doesn’t pass context information to the called page.