Interview Tips Interview Tips, Interview Questions and Answers

13Apr/100

asp.net interview: How to pass values between pages?

Every interviewer will expect this from you. There are several methods to pass values from one page to another page. Described below are few methods to pass values between pages:
QueryString - The QueryString method of passing values between web pages is one of the oldest methods of passing values between pages. A variable value is properly encoded before it is placed on a querystring. This is to make sure that characters that cause problems (like symbols and spaces) are encoded correctly. See the code below to see how QueryString functionality works.

//Code in InitialPage.aspx
String sString;
sString = Server.UrlEncode("string in InitialPage.aspx");
Response.Redirect("DestinationPage.aspx?Value=" & sString);
//Code in DestinationPage.aspx reads the QueryString
String sString;
sString = Request.QueryString("Value");
Response.Write("Your name is " & sString);
The data in the DestinationPage.aspx in the URL looks like this...
http://www.dotnetuncle.com/DestinationPage.aspx?Value=dotnetUncle

Context - The context object is used to send values between pages. Its similar to the session object, the difference being that, the Context object goes out of scope when the page is sent to a browser. Example code below shows how to use Context object.

'InitialPage.aspx stores value in context before sending it
Context.Items("MyData") = "dotnetuncle";
Server.Transfer("DestinationPage.aspx");
'DestinationPage.aspx retrieves the value from InitialPage.aspx's context
String sString;
sString = Context.Items("MyDate").ToString;
Response.Write("The data is as follows: " & sString);

Session - The session object is used to persist data across a user session during the user's visit to a website. It is almost same as the Context object. When we use Response.Redirect, it causes the Context object to go away, so rather the Session object is used in such a scenario. Session object uses more of server memory than a context object. Example code below shows how to use Session object.

'InitialPage.aspx stores value in session before sending it
Session.Items("MyData") = "dotnetuncle";
Response.Redirect("DestinationPage.aspx");
'DestinationPage.aspx retrieves the value from InitialPage.aspx's session
String sString;
sString = Session.Items("MyDate").ToString;
Response.Write("The data is as follows: " & sString);

12Apr/100

asp.net interview questions on cookie

The cookie object is the essence of any interview, be it ASP NET interview or Java interview or PHP interview.
Cookie - A cookie is a piece of data that is stored on a user's browser. Thus, a cookie does not use any server memory. It is actually a small text file which is created by the broswer on the hard disk of the user. It is actually a piece of information in the form of text strings. A web server sends a cookie to a user (client browser) and then the browser stores it.
A cookie is used to store information of a user & information about a user's preferences. How does the cookie works? - When a user visits a site, say www.amazon.com, and creates a profile out there, the server sends an ID (basically an ID to track this user) and saves the ID through the user's browser in the form of a cookie on the user's system. When the user revisits this site, the website tracks the user's system for the existence of any cookie, and in case it finds a cookie, it customizes the site based on the user's settings and preferences.
Now lets talk about how to create a cookie in ASP.NET. It is pretty simple. There is a class in the System.Web namespace by the name HttpCookie. This class may be used to easily create a cookie on the user's system. Below is a code sample on how to use a cookie in ASP.NET ...

//Creating a cookie HttpCookie sampleCookie = new HttpCookie("UserColorSetting");
sampleCookie.Values.Add("Background", txtBackgroundColor.Text);
sampleCookie.Expires = #12/31/2010#; Response.Cookies.Add(sampleCookie);
//Getting a cookie value from the user's computer
String sGetCookie;
sGetCookie = Request.Cookies("UserColorSetting")("Background").ToString();

Limitations of Cookies - Cookies are meant for infrequent storage of small pieces of information. They are not meant as a normal communication or mechanism. Note that web browsers are not required to save more than 300 cookies total, nor more than 20 cookies per web server (for the entire server, not just for the page or site on the server), nor to retain more than 4 kilobytes of data per cookie (both name and value count towards this 4 kilobyte limit). The biggest limitation of these is the 20 cookies per server limit, and so it is not a good idea to use a different cookie for each variable that has to be saved. Rather save a single cookie containing a lot of information.

11Apr/100

asp.net interview: How to redirect a page to another page?

A common question asked in interviews. The Response object has a famous Redirect method that is used most widely to transfer a web page visitor from one page to another page.

Syntax of Response.Redirect ...
Response.Redirect("DestinationPage.aspx")

There is another famous method called Transfer method of the Server object.

Syntax of Server.Transfer ...
Server.Transfer("DestinationPage.aspx")

11Apr/100

asp.net interview: creating a cookie from source using c#

 

protected void Page_Load(object sender, EventArgs e)
{
    HttpCookie cookie = Request.Cookies["maid"];  
    if (cookie == null)  
    {  
        cookie = new HttpCookie("maid");  
    }

    cookie["id"] = "123";  
    cookie.Expires = DateTime.Now.AddMinutes(10);  
    Response.Cookies.Add(cookie);  
}

2Apr/100

3 Ways to Negotiate a Better Job Offer

1. Get a potential employer to "fall in love" with you before you talk about money.
The time to be asking for things is after an employer has decided to hire you. Focus on what is important to the employer and what you can do for them. In tough times, making or saving money is always important. So is your ability to make your prospective boss look good.

Employers want to hire people who bring value, and they are willing to pay what is necessary to hire them. Once the employer has decided to make you an offer, then, and only then, should you start discussing the terms of employment. Until that time, whenever the subject of money comes up, talk about the job. Be enthusiastic about wanting the job. Show that you really want to work there. Ask for the job. No one wants to hire a person who is only looking for a paycheck.

If asked what you are looking for in terms of compensation, say something like "I am sure that if I am the right person for the job and the job is right for me, something that is fair will be readily worked out." Then ask some questions about the job. You will look good to the employer and defer the conversation until a time that is more appropriate.

2. The only difference between being employed and being unemployed is your self-confidence. 
You are same person when you are unemployed as you were when you were working. You have the same skills and same experience. The value you can bring to an employer doesn't change just because you don't have a job. The only difference is your confidence. If you exhibit confidence you not only can negotiate effectively, you probably can land the job you want.

Competition for your services will also make you seem more valuable in the eyes of a prospective employer. Talking with several prospective employers at the same time will not only increase your confidence but will enhance your bargaining leverage.

3. Don't act like you are negotiating.
While you want to arrange the best possible deal, you should do so in a way that doesn't look like you are negotiating. Remember, once the employer has decided to offer you a job, they are trying to recruit you. Let them. Tell them what your concerns are. Ask for the things you want without ever suggesting that you won't accept the job if you don't get them. "Would it be possible..." or "Could you..." or 'Other companies I have been talking to have offered, is it possible...." are non-threatening ways for you to ask. Don't make "demands." Throughout the process, and especially when you are asking for something, let the employer know how excited you are about the opportunity and how much you want the job.

1Apr/100

Database Interview: What is fillfactor? What is the use of it ? What happens when we ignore it? When you should use low fill factor?

When you create a clustered index, the data in the table is stored in
the data pages of the database according to the order of the values in
the indexed columns. When new rows of data are inserted into the table
or the values in the indexed columns are changed, Microsoft® SQL
Server™ 2000 may have to reorganize the storage of the data in the
table to make room for the new row and maintain the ordered storage of
the data. This also applies to nonclustered indexes. When data is
added or changed, SQL Server may have to reorganize the storage of the
data in the nonclustered index pages. When a new row is added to a
full index page, SQL Server moves approximately half the rows to a new
page to make room for the new row. This reorganization is known as a
page split. Page splitting can impair performance and fragment the
storage of the data in a table.
When creating an index, you can specify a fill factor to leave extra