ASP.NET Interview Questions and Answers (1544) - Page 15

What is capacity and length for StringBuilder ?

By specifying capacity you can indicate number of characters the instance object of stringbuilder can hold while the length is the character count of the string the stringbuilder holds.
Specifying lesser capacity and longer string will make capacity to get expanded to accommodate the supplied string. But specifying higher capacity and lesser length will shorten the string content.
Unless specified, the default capacity of the stringbuilder is 16.

    Dim sb As New StringBuilder("Hi", 5) ' initial capacity is set to 5

Response.Write(sb.Capacity) ' will print 5
Response.Write(sb.Length) ' will print 2
sb.Append(" testing")
Response.Write(sb.Capacity) ' will print 10
Response.Write(sb.Length) ' will print 10
sb.Length = 5
Response.Write(sb) ' will print hi te

can we use session variable in App_code Class page ?

Yes.
By using "HttpContext.Current.Session("VarName") ", we can use current session variable in App_code Class page
How to redirect user to secure connection ?

To redirect user to https(to a secure connection), you can define uri scheme to UriSchemeHttps.

UriBuilder testuri = new UriBuilder(Page.Request.Url);

testuri.Scheme = testuri.UriSchemeHttps;

How will you make strings with TitleCase ?

With dynamic pages, sometimes you need to create titles dynamically. At such stage you can not go back to check whether they are stored in proper Title case or not. To make this task happen you can use string class provided toUpper() and toLower() methods but that would be much time consuming and tedious job. You can use, titlecase() method to make it single linear task.
Dim strTest As String = "testing title case"

strTest = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(strTest.ToLower()) ' will result Testing Title Case

How does ASP.NET store SessionIDs by default?

NOTE: This is objective type question, Please click question title for correct answer.
Using which property you can check on the server whether validators controls are satisfied or not?

The answer is Page.IsValid . Always ensure that you check Page.IsValid before doing any kind of operation when working with Validator Controls.
The capacity of the stringbuilder get increased,…

NOTE: This is objective type question, Please click question title for correct answer.
How can we make file hidden ?

With C# or VB, we just need to set attribute of file as “Hidden” to make it hidden.
f.Attributes = FileAttributes.Hidden ‘f is New FileInfo(filePath)

Elements of jagged array are of…

NOTE: This is objective type question, Please click question title for correct answer.
What is the difference between UniqueID and ClientID?

Well, both the properties are associated with asp.net control. The difference is Unique ID has '$' (Dollar) sign and Client ID adds '_' (hyphen) to the control, if master page is used.

Let's say you have placed a text box called 'txtName' in content place holder. So client ID will be ct100_ContentPlaceHolder1_txtName where Unique ID will be ct100$ContentPlaceHolder1$txtName.

ClientID is used to access control in Java Script where using Unique ID you can make a post back using java script __doPostBack() function.

Thanks,
Virendra Dugar
Is it possible to read Web.config or Global.asax files from browser?

No. It is not possible . As Machine.Config file has configuration settings which has entries that maps to CONFIG files, ASAX file with an HTTP handler "HttpForbiddenHandler", which prevents to retrieve the associated file.
Can I make viewstate enabled for controls where Enableviewstate of the container page is set to false?

No.
You can set it to true or false as per your requirement but in fact it will not have any effect to the controls. Because viewstate in ASP.NET has hierarchical nature. Hence, following code will not work if you have set EnableViewState = false; for page.
protected void Page_Load(object sender, EventArgs e)

{
txtTest.EnableViewState = true;
}

Can you find label placed in footer template of repeater in itemdatabound event of the same?

No. You can’t find this item.
Because the second argument of the event is RepeaterItemEventArgs, which doesn’t include footer items into them.
What is PLINQ

PLIONQ stands for parallel LINQ. As the name clearly implies it is parallel implementation of LINQ to Objects.
(Introduced with VS 2010)
Where are shared assemblies stored?

In Global assembly cache.
Found this useful, bookmark this page to the blog or social networking websites. Page copy protected against web site content infringement by Copyscape

 Interview Questions and Answers Categories