Interview Tips Interview Tips, Interview Questions and Answers

22Jun/110

ASP.Net Listview Databinding

ASP. Net ListView DataBinding

For presenting data like a list, we have tons of options in Asp.Net like ListView, DataList, Repeater, GridView, DropDownList, etc... Since we have a array of controls to choose from, the control can be selected based on specific requirements. For e.g. there is a need of selecting a single column then DropDownList is the perfect choice. If paging, sorting, edit is required then GridView will be the ideal choice. If just need to repeat some html code, then Repeater will work out to be better. This article is mainly focused on VB.Net ListView DataBinding.
DataBinding is quiet similar to GridView

DataBinding in ListView is almost similar to GridView. There is not much noticeable difference. There should be atleast one ItemPlaceHolder present in the template. By default the name of that is itemPlaceholder. Asp.Net allows us to custom name (id) also for easy reading.
Flexibility in rendering

This ListView is one of the best controls while flexibility is taken into consideration. With the concept of Item Place Holder, we can specify/ configure where the items have to be placed (rotated). In this example, I have made a two column liquid layout . The number of horizontal cells can be adjusted based on the resolution while resizing the browser.
Templates in ListView

There are few templates that will ease the development effort using ListView. If you have worked in GridView earlier, then basic templates in ListView are similar to GridView Templates. There are few special templates. I am highlighting the templates in the following list. These templates can be used customize rendering.

LayoutTemplate
GroupTemplate
ItemTemplate
AlternatingItemTemplate
EditItemTemplate
InsertItemTemplate
ItemSeparatorTemplate
GroupSeparatorTemplate
EmptyItemTemplate
EmptyDataTemplate
SelectedItemTemplate

18Jun/110

how to upload an excel in c# ASP.Net?

protected void btnUpload_Click(object sender, EventArgs e)
    {
        if (fuUpload.HasFile)
        {
            string filename = fuUpload.PostedFile.FileName;

            string strConn;
            strConn = "Provider=Microsoft.Jet.OLEDB.4.0;"
+"Data Source="+ filename +";" +"Extended Properties=Excel
8.0;";
            OleDbConnection con = new OleDbConnection(strConn);
            con.Open();
            OleDbCommand cmd = new OleDbCommand("select *
from [Sheet1$]",con);
            OleDbDataAdapter dad = new OleDbDataAdapter();
            dad.SelectCommand = cmd;
            DataSet ds= new DataSet();
            dad.Fill(ds);
            DataGrid1.DataSource = ds.Tables[0].DefaultView;
            DataGrid1.DataBind();
            con.Close();
        }

    }
22Oct/100

ASP.NET Session State

ASP.NET session state solves all of the above problems associated with classic ASP session state:

* Process independent. ASP.NET session state is able to run in a separate process from the ASP.NET host process. If session state is in a separate process, the ASP.NET process can come and go while the session state process remains available. Of course, you can still use session state in process similar to classic ASP, too.
* Support for server farm configurations. By moving to an out-of-process model, ASP.NET also solves the server farm problem. The new out-of-process model allows all servers in the farm to share a session state process. You can implement this by changing the ASP.NET configuration to point to a common server.
* Cookie independent. Although solutions to the problem of cookieless state management do exist for classic ASP, they're not trivial to implement. ASP.NET, on the other hand, reduces the complexities of cookieless session state to a simple configuration setting.

11Oct/100

Hosting ASP.NET Pages

Hosting ASP.NET pages locally through the ASP.NET Development Web Server has a number of advantages:

* Testing can be done while offline-Because the request from your browser is being directed to your own personal computer, you don’t need to be connected to the Internet to test your ASP.NET pages.
* It’s fast-Local requests are, naturally, much quicker than requests that must travel over the Internet.
* Advanced debugging features are available-By developing locally, you can use advanced debugging techniques, such as halting the execution of an ASP.NET page and stepping through its code line-by-line.
* It’s secure-The ASP.NET Development Web Server allows only local connections. With this lightweight web server, you don’t need to worry about hackers gaining access to your system through an open website.

The main disadvantage of hosting ASP.NET pages locally is that they can be viewed only from your computer. That is, a visitor on another computer cannot enter some URL into her browser’s Address bar that will take her to the ASP.NET website you’ve created on your local computer. If you want to create an ASP.NET website that can be visited by anyone with an Internet connection, you should consider using a web-hosting company.

Web-hosting companies have a number of Internet-accessible computers on which individuals or companies can host their websites. These computers contain web servers that are accessible from any other computer on the Internet. Hour 24, “Deploying Your Website,” explores how to move an ASP.NET website from your personal computer to a web-hosting company’s computers. After a website has been successfully deployed to a web-hosting company, you, or anyone else on the Internet, can visit the site.

10Sep/100

What is Fragment Caching in ASP.NET?

  • Fragment caching refers to the caching of individual user controls within a Web Form. 
  • Each user control can have independent cache durations and implementations of how the caching behavior is to be applied.
  • Fragment caching is useful when you need to cache only a subset of a page. 
  • Navigation bars, header, and footers are good candidates for fragment caching.
15Jul/100

Explain the ways of authentication techniques in ASP.NET

Selection of an authentication provider is done through the entries in the web.config file for an application.

The modes of authentication are:

<authentication mode=”windows”>
<authentication mode=”passport”>
<authentication mode=”forms”>

Custom authentication needs installation of ISAPI filter in IIS. It compares incoming requests to a list of source IP addresses and a request is considered to be authenticated if it comes from an acceptable address.

12Jul/100

Describe how the ASP.NET authentication process works

ASP.NET runs inside the process of IIS due to which there are two authentication layers which exist in the system.

First authentication happens at the IIS level and the second at ASP.NET level per the WEB.CONFIG file.

Working:

At first, IIS ensures that the incoming request is from an authenticated IP address.
Otherwise the request is rejected.

By default IIS allows anonymous access due to which requests are automatically authenticated.

However, if this is changed, IIS performs its own user authentication too.

ASP.net checks if impersonation is enabled if a request is passed to ASP.net by an authenticated user. If it is enabled, ASP.net acts itself as an authenticated user else it acts with its own configured account.

Finally the OS resources are requested by the identity obtained from previous step.
The user is granted the resources if the authentication is successful else the resources are denied.

Resources can include ASP.net page, code access security features to extend authorization step to disk files, registry keys, etc.