ASP .Net Interview Question Answers - 4

ASP .Net Interview Question Answers - 4



• What tags do you need to add within the asp:datagrid tags to bind columns manually?


<. asp:DataGrid id="dgCart" AutoGenerateColumns="False" CellPadding="4" Width="448px" runat="server" .>
<. Columns .>
<. asp:ButtonColumn HeaderText="SELECT" Text="SELECT" CommandName="select" .><. /asp:ButtonColumn >
<. asp:BoundColumn DataField="ProductId" HeaderText="Product ID" ><. /asp:BoundColumn .>
<. asp:BoundColumn DataField="ProductName" HeaderText="Product Name" .><. /asp:BoundColumn .>
<. asp:BoundColumn DataField="UnitPrice" HeaderText="UnitPrice" >< /asp:BoundColumn .>
<. /Columns .>
<. /asp:DataGrid .>

• How do you create a permanent cookie?
Permanent cookies are the ones that are most useful. Permanent cookies are available until a specified expiration date, and are stored on the hard disk. The location of cookies differs with each browser, but this doesn’t matter, as this is all handled by your browser and the server. If you want to create a permanent cookie called Name with a value of Nigel, which expires in one month, you’d use the following code
Response.Cookies ("Name") = "Nigel"
Response.Cookies ("Name"). Expires = DateAdd ("m", 1, Now ())

• What tag do you use to add a hyperlink column to the DataGrid?
<. asp:HyperLinkColumn .> <./ asp:HyperLinkColumn.>

• Which method do you use to redirect the user to another page without performing a round trip to the client?
Server.transfer

• What is the transport protocol you use to call a Web service SOAP ?
HTTP Protocol

• Explain role based security ?
Role Based Security lets you identify groups of users to allow or deny based on their role
in the organization.In Windows NT and Windows XP, roles map to names used to identify user groups. Windows defines several built-in groups, including Administrators, Users, and Guests.To allow or deny access to certain groups of users, add the <.ROLES.>element to the authorization list in your Web application's Web.config file.e.g.
<.AUTHORIZATION.><>
<. allow roles="Domain Name\Administrators" / .> <. !-- Allow Administrators in domain. -- >
<. deny users="*" / .> <. !-- Deny anyone else. -- .>
<. /authorization .>

• How do you register JavaScript for webcontrols ?
You can register javascript for controls using Attribtues.Add(scriptname,scripttext) method.

• When do you set "<.IDENTITY impersonate="true" /.>" ?
Identity is a webconfig declaration under System.web, which helps to control the application Identity of the web applicaton. Which can be at any level(Machine,Site,application,subdirectory,or page), attribute impersonate with "true" as value specifies that client impersonation is used.

• What are different templates available in Repeater,DataList and Datagrid ?
Templates enable one to apply complicated formatting to each of the items displayed by a control.Repeater control supports five types of templates.HeaderTemplate controls how the header of the repeater control is formatted.ItemTemplate controls the formatting of each item displayed.AlternatingItemTemplate controls how alternate items are formatted and the SeparatorTemplate displays a separator between each item displyed.FooterTemplate is used for controlling how the footer of the repeater control is formatted.The DataList and Datagrid supports two templates in addition to the above five.SelectedItem Template controls how a selected item is formatted and EditItemTemplate controls how an item selected for editing is formatted.

• What is ViewState ? and how it is managed ?
ASP.NET ViewState is a new kind of state service that developers can use to track UI state on a per-user basis. Internally it uses an an old Web programming trick-roundtripping state in a hidden form field and bakes it right into the page-processing framework.It needs less code to write and maintain state in your Web-based forms.

• What is web.config file ?
Web.config file is the configuration file for the Asp.net web application. There is one web.config file for one asp.net application which configures
the particular application. Web.config file is written in XML with specific tags having specific meanings.It includes databa which includes
connections,Session States,Error Handling,Security etc.
For example :
<. configuration .>
<. appSettings .>
<. add key="ConnectionString" value="server=localhost;uid=sa;pwd=;database=MyDB" / .>
<. /appSettings .>
<. /configuration .>

• What is advantage of viewstate and what are benefits?
When a form is submitted in classic ASP, all form values are cleared. Suppose you have submitted a form with a lot of information and the server comes back with an error. You will have to go back to the form and correct the information. You click the back button, and what happens.......ALL form values are CLEARED, and you will have to start all over again! The site did not maintain your ViewState.With ASP .NET, the form reappears in the browser window together with all form values.This is because ASP .NET maintains your ViewState. The ViewState indicates the status of the page when submitted to the server.

• What tags do you need to add within the asp:datagrid tags to bind columns manually?
Set AutoGenerateColumns Property to false on the datagrid tag and then use Column tag and an ASP:databound tag
<. asp:DataGrid runat="server" id="ManualColumnBinding" AutoGenerateColumns="False" .>
<. Columns .>
<. asp:BoundColumn HeaderText="Column1" DataField="Column1"/ .>
<. asp:BoundColumn HeaderText="Column2" DataField="Column2"/ .>
<. /Columns .>
<. /asp:DataGrid .>

<.COLUMNS.> <.asp:BoundColumn HeaderText="Column2" DataField="Column2".><./asp:BoundColumn.>
<./asp:DataGrid.>

• Which property on a Combo Box do you set with a column name, prior to setting the DataSource, to display data in the combo box?
DataTextField and DataValueField

• Which control would you use if you needed to make sure the values in two different controls matched?
CompareValidator is used to ensure that two fields are identical.

• What is validationsummary server control?where it is used?.
The ValidationSummary control allows you to summarize the error messages from all validation controls on a Web page in a single location. The summary can be displayed as a list, a bulleted list, or a single paragraph, based on the value of the DisplayMode property. The error message displayed in the ValidationSummary control for each validation control on the page is specified by the ErrorMessage property of each validation control. If the ErrorMessage property of the validation control is not set, no error message is displayed in the ValidationSummary control for that validation control. You can also specify a custom title in the heading section of the ValidationSummary control by setting the HeaderText property.
You can control whether the ValidationSummary control is displayed or hidden by setting the ShowSummary property. The summary can also be displayed in a message box by setting the ShowMessageBox property to true.

• What is the sequence of operation takes place when a page is loaded?
BeginTranaction - only if the request is transacted
Init - every time a page is processed
LoadViewState - Only on postback
ProcessPostData1 - Only on postback
Load - every time
ProcessData2 - Only on Postback
RaiseChangedEvent - Only on Postback
RaisePostBackEvent - Only on Postback
PreRender - everytime
BuildTraceTree - only if tracing is enabled
SaveViewState - every time
Render - Everytime
End Transaction - only if the request is transacted
Trace.EndRequest - only when tracing is enabled
UnloadRecursive - Every request

• Difference between asp and asp.net?.
"ASP (Active Server Pages) and ASP.NET are both server side technologies for building web sites and web applications, ASP.NET is Managed compiled code - asp is interpreted. and ASP.net is fully Object oriented. ASP.NET has been entirely re-architected to provide a highly productive programming experience based on the .NET Framework, and a robust infrastructure for building reliable and scalable web
applications."

Share this

Related Posts

There was an error in this gadget