91) What is Reflection?
Reflection is a mechanism through which types defined in the metadata of each module can be accessed. The System.Reflection namespace will have the classes that can be used to define the types for an assembly.
<configuration>
<system.web>
<compilation debug="true"/>
<httpHandlers>
<add verb="*" path="*.xsl" type="Handler" />
</httpHandlers>
</system.web>
</configuration>
string constr = ConfigurationManager.ConnectionStrings["TestMyconnectionstring"].ToString();
<authorization>
<allow roles=”roles to be allowed” <!—Allowing the roles. -->
<deny users =”*”/>
</authorization>
<configuration>
<system.web>
<pages theme=”windows 8”>
</system.web>
</configuration>
- System.Resources and
- System.Globalization
Yes of course we can do it. We can create some web pages with C# language and some pages in VB.NET but the same is false when we mix up multiple programming languages in the same project because each project will be built to a single dll.
98) How can we change a Master Page at runtime?
Using page events we can change the master page during runtime. In Page_PreInit() event we can change the master page by setting the “MasterPageFile” property to the path of the master page what we have to set.
99) What are Application Pools?
Once the web application is deployed into IIS, we can set the Application Pool to the website directory where web application hosted/deployed. Application Pool is assigned to the website to make it secure and confidential. Multiple websites can be assigned under a single application pool which in turn will be under a single worker process. (Multiple worker process can also be assigned for a single application pool in the settings).
100) Why “AutoEventWireup” is used?
AutoEventWireup is used for wiring up the events in page so that it can be given at the page level. Value of this attribute is Boolean (true or false). By default it is set to “true” for C# web form where as, it is “false” for VB.NET web forms.
101) Performance wise which is better, Session or ViewState?
- For large amount of data, Session will be an efficient way to go. When session is not used, set it to null for memory overhead but this cannot be done in all the cases. Once the session timeout happened it automatically set to null. Default timeout is 20 minutes.
- In Viewstate, all data will be stored in HTML hidden fields. For large amount of data, it would give performance issues. Ideal size of viewstate should not be more than 20-30% of page size. So for less data viewstate will be an ideal solution.
102) How to display all validation messages in validation controls?
By adding ValidationSummary control to web page we can display all the validation messages related to different validation controls.
103) Why to use "Orientation" property of Menu control?
Orientation property is used to set the display of menu vertically or horizontally. By default the value of this property is vertical.
104) How to kill a user session?
When a user logs into the website, it’s a good practice to create a new session to track the user activities. So, meantime we need to handle log out scenario as well. So, we will kill a user session once user logs out of the application. Below is the code snippet that can be written to kill the user session –
- Session.Abandon();
105) How to use a checkbox in a gridview?
Following are the steps to be used. Add Itemtemplate tag in gridview like below -
<ItemTemplate>
<asp:CheckBox id="TestMyCheckBox" runat="server" AutoPostBack="True" OnCheckedChanged="Check_Clicked"></asp:CheckBox>
</ItemTemplate>
If you look at the Itemtemplate we have “OnCheckChanged” event. This “OnCheckChanged” event has “Check_Clicked” subroutine which actually resides in behind code and this method should either be “protected” or “public”. Sample code snippet shown below –
Protected Sub Check_Clicked(ByVal senderobj As Object, ByVal e As EventArgs)
// do something
End Sub
106) How can we format data inside Gridview?
We can format data using – “DataFormatString” property.
107) How do you upload a file in ASP.NET?
ASP.NET provides two controls that lets user to upload files to server. Once web server receives the file, it can take any actions on that file. Controls used for uploading file are –
- FileUpload – This is an ASP.NET control.
- HtmlInputFile – This is HTML Server control.