Interview Question


What data type does the RangeValidator control support?
Integer,String and Date.
Suppose you want a certain ASP.NET function executed on MouseOver overa certain button. Where do you add an event handler?
It’s the Attributesproperty,
the Add function inside that property. So

btnSubmit.Attributes.Add("onMouseOver","someClientCode();")

A simple”Javascript:ClientCode();” in the button control of the .aspx page will attach the handler (javascript function)to the onmouseover event. 
Where does the Web page belong in the .NET Framework class hierarchy?
System.Web.UI.Page
Where do you store the information about the user’s locale?
System.Web.UI.Page.Culture
What’s the difference between Codebehind="MyCode.aspx.cs" andSrc="MyCode.aspx.cs"?
CodeBehind is relevant to Visual Studio.NET only.
What’s a bubbled event?
When you have a complex control,  like DataGrid, writing an event processing routine for each object (cell, button, row, etc.) is quite tedious. The controls can bubble up their event handlers, allowing the main DataGrid event handler to take care of its constituents. 
Describe the role of inetinfo.exe, aspnet_isapi.dll andaspnet_wp.exe in the page loading process.
inetinfo.exe is theMicrosoft IIS server running, handling ASP.NET requests among other things.When an ASP.NET request is received (usually a file with .aspx extension),the ISAPI filter aspnet_isapi.dll takes care of it by passing the request tothe actual worker process aspnet_wp.exe.
What’s the difference between Response.Write() andResponse.Output.Write()?
The latter one allows you to write formattedoutput.
What methods are fired during the page load?
Init() - when the pageis
instantiated, Load() - when the page is loaded into server memory,PreRender()
- the brief moment before the page is displayed to the user asHTML, Unload()
- when page finishes loading.
 

 

 

DataSets and DataAdapters:-

1)Difference between DataSets and DataAdapters?

Datasets store a copy of data from the database tables. However, Datasets can not directly retrieve data from Databases.
DataAdapters are used to link Databases with DataSets.DataSets and DataAdapters are used to display and manipulate data from databases


2)What is DataSet?
A Dataset is a in memory representation of a collection of Database objects including tables of a relational database scheme.
The dataset contains a collection of Tables, Relations, constraints etc.,

How to create xml file?

1)Select the table values from database
2)bind the values to Dataset
3)dataset to xmlDataDocument
4)Give the xml filename and save to current location.
[code]
Imports System.Data
Imports System.Data.SqlClient
Imports System.Xml

Partial Class _Default
Inherits System.Web.UI.Page

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim strConn As String
'create connection to database table.
strConn = "USER=asd;PASSWORD=45646;SERVER=qwer;DATABASE=Emp"
Dim MySQL As String = "Select empno, empname from kk"
Dim MyConn As New SqlClient.SqlConnection(strConn)
Dim ds As DataSet = New DataSet()
Dim Cmd As New SqlClient.SqlDataAdapter(MySQL, MyConn)
'Fill the Table values to Dataset
Cmd.Fill(ds, "Emptbl")
'Bind the dataset values to xmldatadocument
Dim doc As New XmlDataDocument(ds)
doc.Save(MapPath("NewXMLName.xml"))
'This is where we are saving the data in an XML file NewXMLName.xml
End Sub
End Class

[/code]
The output look like
[code]
< NewDataSet >
< Emptbl>
< empno>3< /empno>
< empname>777
< /Emptbl>
< Emptbl>
< empno>344< /empno>
< empname>rrr677 < /empname>
< /Emptbl>
< Emptbl>
< empno>3< /empno>
< empname>ggg'D < /empname>
< /Emptbl>
< Emptbl>
< empno>4< /empno>
< empname>d < /empname>
< /Emptbl>
< Emptbl>
< /Emptbl>
< /NewDataSet>
[/code]

How to check whether any of the radiobutton selected or not?

[code]
using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
protected void RadioButtonList1_SelectedIndexChanged(object sender, EventArgs e)
{
string str;
if (RadioButtonList1.SelectedIndex != -1)
{
str = RadioButtonList1.SelectedItem.Text.ToString();
Response.Write(str);
}


}
}


<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %&>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&>

<html xmlns="http://www.w3.org/1999/xhtml"&>
<head runat="server"&>
<title&>Untitled Page</title&>
</head&>
<body&>
<form id="form1" runat="server"&>
<div&>
<asp:RadioButtonList ID="RadioButtonList1" runat="server" AutoPostBack="True"&>
<asp:ListItem&>ABC</asp:ListItem&>
<asp:ListItem&>AB</asp:ListItem&>
<asp:ListItem&>A</asp:ListItem&>
</asp:RadioButtonList&>
</div&>
</form&>
</body&>
</html&>

[/code]

How to convert DataReader to DataTable?

Just Drag and drop Grid view control to your web page

[code]
using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
ConvertDateReadertoTableUsingLoad();
}
private void ConvertDateReadertoTableUsingLoad()
{
SqlConnection conn = null;

string connString = "server=servername;database=databasename;uid=userid;password=password;";
conn = new SqlConnection(connString);
string query = "select * from Tablename";
SqlCommand cmd = new SqlCommand(query, conn);
conn.Open();
SqlDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
DataTable dt = new DataTable();
dt.Load(dr);
conn.Close();
GridView1.DataSource = dt;
GridView1.DataBind();

}

}



[/code]