Wednesday, 23 April 2014

What is the In-Page Technique in Asp.Net

In this method we will create single file only with .aspx extention. This file will be split into two parts. one part will be ServerSide (s/s) code and remaining part will be design code. 
Server side code part is identified not with <% ----%> block but with again <Script> tag with an attribute runat="server".

How to Consume Application /Session objects for our Project in Asp.Net

We can consume both these objects in two ways
a.      In the form of variables for StateManagement.
b.      In the form of events using Global.ASAX file.
Global.ASAX File :
  1. 1.      These file is called active server application file and it should be located in root directory of projects.
  2. 2.      A project can have only one Global.ASAX file.
  3. 3.      It is called as application file because for every request first these file is executed and then the requested resource.
  4. 4.      The content of Global.ASAX is all application and session  evernts. We can use these file for performing unique tasks related to application.
  5. 5.      By default in an asp.net project it is not added . we have to explicitly add it using add new item. For some of the projects Global.ASAX is compulsory and it is added along with project only like MVC, dynamic data project etc.

What is Size of empty class

ans) 1 byte

How many Controls in Asp.net


Ans) 90 + controls

How to Clear the Gridview using asp.net?

Source code : 


 <asp:GridView ID="GridViewID" runat="server" 
     AllowSorting="true" AutoGenerateColumns="False"
     AllowPaging="true" CellPadding="4" DataKeyNames="DemoId"               EmptyDataText='No Records Found.'
      ForeColor="#333333" HeaderStyle-Font-Bold="true"  ShowFooter="False" Width="100%" PageSize="5">
   <EmptyDataRowStyle BackColor="White" BorderWidth="0px" />
   <PagerSettings Position="TopAndBottom" />
   <RowStyle BackColor="White" ForeColor="Black" />
   <PagerStyle BackColor="White" />
   <HeaderStyle Font-Bold="False" />
 </asp:GridView>


Server-side code:

Private Sub ClearGrid(ByVal gvw As GridView)
       gvw.DataSource = Nothing
            gvw.EditIndex = -1
            gvw.DataBind()
       
    End Sub
Call the method in Page Load:
If (Page.IsPostBack = False) Then
ClearGrid(GridViewID)
End If

Screen shot of clear Gridview when loading the page :




What are the Hierarchical Data Controls in Asp.net

There are Two types of Hierarchical Data controls 
1.XmlDataSource
2.SiteMapDataSource

What is Data Control in Asp.net

There are different Data Controls available
1. Gridview
2.DataList
3.Repeater
4. DetailsView
5.FormsView
6.ListView