Asp .Net Interview Question and Answer | Web Application | Session 16

141. Difference Between Thread and Processs?
Ans: Process is a program in execution where thread is a seprate part of execution in the program.
         Thread is a part of process. process is the collection of thread.
 
142. How does cookies work in ASP.Net?
Ans: Using Cookies in web pages is very useful for temporarily storing small amounts of data, for the website to use. These Cookies are small text files that are stored on the user's computer, which the web site can read for information; a web site can also write new cookies.
An example of using cookies efficiently would be for a web site to tell if a user has already logged in. The login information can be stored in a cookie on the user's computer and read at any time by the web site to see if the user is currently logged in. This enables the web site to display information based upon the user's current status - logged in or logged out.
 
143. A) What is ASP.Net?
Ans: ASP Stands for Active server Pages.ASP used to create interacting web pages.
        
       B) 129 What is Benefits of ASP.NET? 
Ans:
      >>Simplified development:
ASP.NET offers a very rich object model that developers can use to reduce the amount of code they need to write.

      >>Web services:
Create Web services that can be consumed by any client that understands HTTP and
XML,  the de facto language for inter-device communication.

      >>Performance:
When ASP.NET page is first requested, it is compiled and cached, or saved in memory, by
the .NET Common Language Runtime (CLR). This cached copy can then be re-used for
each subsequent request for the page. Performance is thereby improved because after
the first request, the code can run from a much faster compiled version.

     >>Language independence

     >>Simplified deployment

     >>Cross-client capability

144. How to make User Control in ASP.net? 
Ans: Write code:
      a) Add User Controll:-

<hr color=red/>
<center><H1><SPAN
style="COLOR: #ff9999; TEXT-DECORATION: underline">BigBanyanTree.com</SPAN></H1></center>
<hr Color=Green/>

    b) In .aspx page:-
<%@ Register TagPrefix=a TagName="MyUserCtl" Src="~/WebUserControl.ascx"%>

   c) Now use this :-
     <a:MyUserCtl ID="tata" runat=server/> 
   
   
145. Write a program to show the Use of dataList in ASP.NET?
Ans:
      <asp:DataList ID="DataList1" runat="server" BackColor="White" BorderColor="#336666" BorderStyle="Double" BorderWidth="3px" CellPadding="4" GridLines="Both">
        <HeaderTemplate>Employee Detailed</HeaderTemplate> 
        <ItemTemplate>
                            <%#DataBinder.Eval(Container.DataItem, "Empno") %>
                            <%#DataBinder.Eval(Container.DataItem, "Ename") %>
                            <%#DataBinder.Eval(Container.DataItem, "Sal") %>
        </ItemTemplate>   


146. How to show data in HTML table using Repeater?
Ans:
           <asp:Repeater ID="Repeater1" runat="server">
                    <HeaderTemplate>
                    <table border="10" width="100%"  bgcolor=green  style="width:100%" >
                       <tr>
                       <th>Empno</th> <th>Ename</th> <th>Sal</th>
                       </tr>
                    </HeaderTemplate>
                    <ItemTemplate>
                            <tr>
                            <td>
                            <%#DataBinder.Eval(Container.DataItem, "Empno") %>
                            </td>
                            <td>
                            <%#DataBinder.Eval(Container.DataItem, "Ename") %>
                            </td>
                            <td>
                            <%#DataBinder.Eval(Container.DataItem, "Sal") %>
                            </td>
                            </tr>
                            </font>
                    </ItemTemplate>
                    <FooterTemplate>
                       </table>
                    </FooterTemplate>
                    </asp:Repeater>
                </td>
                <td style="width: 100px; height: 226px">
                </td>
            </tr>
        </table>



147. How Repeater is used in ASP.NET? 
Ans:
     <asp:Repeater ID="Repeater1" runat="server"> <ItemTemplate>
                            <%#DataBinder.Eval(Container.DataItem, "Empno") %>
                            <%#DataBinder.Eval(Container.DataItem, "Ename") %>
                            <%#DataBinder.Eval(Container.DataItem, "Sal") %>
 </ItemTemplate>
 </asp:Repeater>
//the whole structure looks like this
<asp:Repeater ID="Repeater1" runat="server">
<HeaderTemplate>
 Employee Detailed
</HeaderTemplate>
            <ItemTemplate>
               <font color=gray>
                            <%#DataBinder.Eval(Container.DataItem, "Empno") %>
                            <%#DataBinder.Eval(Container.DataItem, "Ename") %>
                            <%#DataBinder.Eval(Container.DataItem, "Sal") %>
                </font>
                </ItemTemplate>
                <AlternatingItemTemplate>
                <font color=green>
                            <%#DataBinder.Eval(Container.DataItem, "Empno") %>
                            <%#DataBinder.Eval(Container.DataItem, "Ename") %>
                            <%#DataBinder.Eval(Container.DataItem, "Sal") %>
                 </font>
                  </AlternatingItemTemplate>
                 <FooterTemplate>
                       Thanks
                </FooterTemplate>
               <SeparatorTemplate>
                        <hr/>
                </SeparatorTemplate>
                </asp:Repeater>   



148. Write a Program to Connect with dropdownlist  in ASP.NET 
 Ans:
     OleDbConnection x;
    OleDbDataAdapter y;
    DataSet z;
    protected void Button1_Click(object sender, EventArgs e)
    {
        x = new OleDbConnection("Provider=msdaora;user         id=scott;password=tiger");
        x.Open();
        y=new OleDbDataAdapter("select * from emp",x);
        z = new DataSet();
        y.Fill(z, "emp");
        DropDownList1.DataSource = z;
        DropDownList1.DataTextField = "ename";
        DropDownList1.DataBind();
        x.Close(); 

    }
 

149. Write a program to show data in Gridview in ASP.NET? 
 Ans:
    OleDbConnection x;
    OleDbDataAdapter y;
    DataSet z;
    protected void Button2_Click(object sender, EventArgs e)
    {
        x = new OleDbConnection("provider=msdaora;user id=scott;password=tiger");
        x.Open();
        y = new OleDbDataAdapter("select * from emp", x);
        z = new DataSet();
        y.Fill(z, "emp");
        GridView1.DataSource = z.Tables["emp"];
        GridView1.DataBind(); 
        y.Dispose();
        x.Close();
    } 



150. Write a program to Delete Record in ASP.NET ?  
Ans:
OleDbConnection x;
    OleDbCommand y;
     protected void Button1_Click(object sender, EventArgs e)
    {
        x = new OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=c:\\db1.mdb");
        x.Open();
        y = new OleDbCommand("delete from emp where empno=@p",x);
        y.Parameters.Add("@p", TextBox1.Text);
        y.ExecuteNonQuery();
        Label1.Visible = true; 
        Label1.Text="Record Deleted";
        y.Dispose();
        x.Close();
 }


 
Previous Next





:: Click the links below for similar type Questions and answers ::

0 comments:

Post a Comment

 
Design by Wordpress Theme | Bloggerized by Free Blogger Templates | coupon codes