Monday 15 June 2015

asp.net interview Qns

how to bind lakh's of records to gridview with in less time in page load?

You need to implement a server side paging technology. There are two kinds of paging and the client side one gets all the records and then just hides some of them. The server side one only requests the amount of data thats needed for a page from the database. 

Interview questions on session management

difference between inproc and outproc session in asp.net?

 Inproc session mode, 
1. session data is stored in current application domain and so consumes memory of server machine.
2. if server restarts, all session data is lost.
Out-proc mode (which is generally state server),
1. session data is stored on state server and so web servers memory is not consumed.
2. in case of web server restart, session data is preserved.
considering above points, use of session mode is the choice to be made considering load, no. of users, performence requirment etc.
for small web site with limited no. of users, in-proc mode is best suited.
for large applications with huge no. of users, state-server/sql server session mode should be used.   

How to add CSS styles for N'th row  of gridview using jquery in asp.net

Include the latest jquery like:
 <script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js"></script>
and add the script tag just before closing body section,

    <script type="text/javascript">

        $("#grid tr:nth-child(n)").css("background-color", "Tan");

    </script>
</body>
OR
 $("table.partnerGridClass tbody tr:nth-child(n)").css("background-color", "green")
Ex:- n=1,2...n

How to get id and text value of control using sender in c#

protected void Button1_Click(object sender, EventArgs e)
    {
        if (sender.GetType().ToString().EndsWith("Button"))
        {
            Button btn = (Button)sender;
            string id = btn.ID;
        }
        if (sender.GetType().ToString().EndsWith("TextBox"))
        {
            TextBox txt = (TextBox)sender;
            string id = txt.ID;
        }
        if (sender.GetType().ToString().EndsWith("CheckBox"))
        {
            CheckBox chk = (CheckBox)sender;
            string id = chk.ID;
        }
    }

what is Ispostback() ?

IsPostback property is used to Gets a value that indicates whether the page is being rendered for the first time or is being loaded in response to a postback.

This IsPostBack property returns the boolean value either True or False.

private void Page_Load()
{
    if (!IsPostBack)
    {
        // Validate initially to force asterisks
        // to appear before the first roundtrip.
        BindDropDown();
    }
}
After render the web page, if you do any post back then it will be called. In the web page, we used to check whether its loaded first time or posted back. Because we do not want to bind the concrete controls to rebind again. It will increase the performance of the web application.

Reference: More

What is the difference between custom controls and user controls?

Custom controls are basically compiled code i.e. DLLs. These can be easily added to toolbox, so it can be easily used across multiple projects using drag and drop approach. These controls are comparatively hard to create.
But User Controls (.ascx) are just like pages (.aspx). These are comparatively easy to create but tightly couple with respect to User Interface and code. In order to use across multiple projects, we need to copy and paste to the other project as well.
Reference: b/n Diffrerence

No comments:

Post a Comment