Monday, January 19, 2009

Code for Approve or Unapprove(Status) in the View Page

Dev Palmistry

Code for Approve or Unapprove (Change the Status) in the View page .

1. In the GridView first we find DataRowBound

protected void GridDisplayCat_RowDataBound(object sender, GridViewRowEventArgs e)
if (e.Row.RowType == DataControlRowType.DataRow e.Row.RowType == DataControlRowType.Separator)

Label lblstatus = (Label)e.Row.Cells[1].FindControl("lblstatus");
Label lblid = (Label)e.Row.Cells[2].FindControl("lblid");
string status = lblstatus.Text.ToString();
string id = lblid.Text.ToString();
if (status.ToString() == "Yes")
e.Row.Cells[1].Text = "(a href=\"ProjectStatus.aspx?setStatus=No&um_id=" + id + "\")(font color=\"#008000\" face=\"Verdana\" size=\"2\")(img src=\"images/approved.gif\" border=\"0\" alt=\"Click here to Close\")(/font)(/a)";
e.Row.Cells[1].Text = "(a href=\"ProjectStatus.aspx?setStatus=Yes&um_id=" + id + "\")(font color=\"#CC3300\" face=\"Verdana\" )(img align=\"absmiddle\" src=\"images/unapprove.gif\" border=\"0\" alt=\"Click here to Open\")(/font)(/a)";

2. In the ProjectStatus.aspx.cs page , we use this page just use the Update the Status and after that page also Response.redirect to the View page....

string status = Request.QueryString["setStatus"].ToString();
string id = Request.QueryString["um_id"].ToString();
string str = "update Project_master set Project_status='" + status + "' where Project_id=" + id + "";
// SqlCommand updatecom = new SqlCommand(str, scon);
OleDbCommand ocom = new OleDbCommand(str, ocon);

Code for Microsoft Access Database Connection

Use this code for MS Access Database connectivity....

1. using System.Data.OleDb;

2. string FileDirectory = Server.MapPath("Database/admin.mdb");
OleDbConnection ocon = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + FileDirectory.ToString() + "");

OleDbDataAdapter osap = new OleDbDataAdapter(str, ocon);

DataSet ds = new DataSet();
osap.Fill(ds, "temp");
GVProjectReports.DataSource = ds;

GroupName Property of RadioButton

For selecting one option , use GroupName property of the RadioButtion.

Using Calendar In The Page

(tr)(td style="width:35%" align="right")
(strong style="font-size: 10pt; font-family: Verdana;")End Date (/strong):(/td)(td style="width:65%" align="left")
(asp:TextBox ID="txtenddate" runat="server" Width="200px")(/asp:TextBox)
(IMG class="calendar.css" id="Img1" onClick="w_displayCalendar('txtenddate',null);"
alt="Select Date" src="images\calendar.gif")
(asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server" ErrorMessage="Please enter End Date" ControlToValidate="txtenddate" Display="Dynamic" Font-Names="Verdana" Font-Size="8pt")

And also use some css files and java script :

(LINK href="includes/calendar.css" type="text/css" rel="StyleSheet")

(SCRIPT language="JavaScript" src="includes/weeklycalendar.js")

(script language="javascript")

Edit in DropDown

private void UpdateAssignment()
string FileDirectory = Server.MapPath("Database/admin.mdb");
OleDbConnection ocon = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + FileDirectory.ToString() + "");
string id = Request.QueryString["id"].ToString();
// SELECT Project_master.Project_name,Project_master.Project_status, , User_master.User_name, Project_assignment.* FROM (Project_assignment INNER JOIN User_master ON Project_assignment.User_id = User_master.User_id) INNER JOIN Project_master ON Project_assignment.Project_id = Project_master.Project_id;"
// string str = "select * from Project_assignment where ProjAssign_id=" + id + "";
string str = "SELECT Project_master.Project_name,Project_master.Project_id,User_master.User_id,Project_assignment.ProiAssig_Allolet_hours as Allotted,Project_assignment.ProjAssig_opening_hours as Projecthours,Project_assignment.ProjAssig_module as Projectmodule,User_master.User_name,Project_assignment.ProjAssign_id, Project_assignment.* FROM (Project_assignment INNER JOIN User_master ON Project_assignment.User_id = User_master.User_id) INNER JOIN Project_master ON Project_assignment.Project_id = Project_master.Project_id where ProjAssign_id=" + id + "";

OleDbCommand ocom = new OleDbCommand(str, ocon);
OleDbDataReader updateReader = ocom.ExecuteReader();
if (updateReader.HasRows)
// txtProName.Text = updateReader["Project_name"].ToString();
// txtEmoName.Text = updateReader["User_name"].ToString();
txtopeninghours.Text = updateReader["Projecthours"].ToString();
txtAlote.Text = updateReader["Allotted"].ToString();
Session["ProjectId"] = updateReader["Project_master.Project_id"].ToString();
txtmodule.Text = updateReader["Projectmodule"].ToString();
// DDteamleader.SelectedIndex = DDteamleader.Items.IndexOf(DDteamleader.Items.FindByValue(updateReader["User_master.User_id"].ToString()));
DDProName.SelectedIndex = DDProName.Items.IndexOf(DDProName.Items.FindByValue(updateReader["Project_master.Project_id"].ToString()));
DDEmpName.SelectedIndex = DDEmpName.Items.IndexOf(DDEmpName.Items.FindByValue(updateReader["User_master.User_id"].ToString()));
catch (Exception ex)


Repeater Contorl within GridView

In the Aspx page :

Ans in the .cs page :

public partial class ProjectReports : System.Web.UI.Page

protected void Page_Load(object sender, EventArgs e)

private void fillGridView()

string FileDirectory = Server.MapPath("Database/admin.mdb");
OleDbConnection ocon = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + FileDirectory.ToString() + "");

string str = "SELECT Project_master.Project_name,Project_master.Project_id, Project_master.Project_total_hours, Project_master.Project_start_date, Project_master.Project_end_date, User_master.User_name" + " " +
"FROM Project_master INNER JOIN User_master ON Project_master.User_id = User_master.User_id";

//string str = "SELECT Project_assignment.ProjAssig_opening_hours, Project_assignment.ProiAssig_Allolet_hours, Project_assignment.ProjAssig_status, Project_master.Project_name, Project_master.Project_total_hours, Project_master.Project_start_date, Project_master.Project_end_date, User_master.User_name" + " " +
//"FROM Project_assignment INNER JOIN (Project_master INNER JOIN User_master ON Project_master.User_id = User_master.User_id) ON Project_assignment.Project_id = Project_master.Project_id";
//String str = "select *,User_name from Project_master inner join User_Master on Project_master.User_id=User_Master.User_id order by Project_master.Project_end_date desc";
OleDbDataAdapter osap = new OleDbDataAdapter(str, ocon);

DataSet ds = new DataSet();
osap.Fill(ds, "temp");
GVProjectReports.DataSource = ds;

catch (Exception ex)

private DataSet FillRepeater(string pid)

string FileDirectory = Server.MapPath("Database/admin.mdb");
DataSet ds = new DataSet();
OleDbConnection ocon = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + FileDirectory.ToString() + "");

string str = "SELECT User_master.User_name,ProjAssig_opening_hours,ProiAssig_Allolet_hours " + " " +
"FROM Project_assignment INNER JOIN User_master ON User_master.User_id = Project_assignment.User_id where Project_assignment.Project_id="+ pid +" ";

OleDbDataAdapter osap = new OleDbDataAdapter(str, ocon);

osap.Fill(ds, "temp");

catch (Exception ex)

return ds;

protected void Button1_Click(object sender, EventArgs e)


private void Update()

protected void GVProjectReports_RowDataBound(object sender, GridViewRowEventArgs e)
if (e.Row.RowType == DataControlRowType.DataRow || e.Row.RowType == DataControlRowType.Separator)

Repeater rep = (Repeater)e.Row.FindControl("ProReport");
Label pid=(Label)e.Row.FindControl("projectID");
Label lblTotHr = (Label)e.Row.FindControl("lblTotHr");
Label _lblRemaingHr = (Label)e.Row.FindControl("lblRemaingHr");

rep.DataSource = FillRepeater(pid.Text);
int totalHr = 0;
foreach (RepeaterItem repe in rep.Items)
Label lblopenAllocated = (Label)repe.FindControl("lblopenHr");
totalHr = totalHr + Convert.ToInt32(lblopenAllocated.Text);

_lblRemaingHr.Text =Convert.ToString((Convert.ToInt32(lblTotHr.Text) - totalHr));


In this Article , Repeater within GridView . In GridView there are there are multiple records. And in the one record means in one row there would appear Repeater and in the Repeater Controle There would also be some record . So Getting this First we get all data in GridView and then we did the same process for the Repeater , but its some titical. For Repeater We have to make DataSet by a function and in the RowDataBound of the GridView we take will find Repeater Control and bind the data throgh rep.DataSource = FillRepeater(pid.Text);
See this function : private DataSet FillRepeater(string pid), here we have taken data type of this function is DataSet becaues we provide DataSet for Reapeater Control. This function is made for collecting the data from DataBase. By this function we collect all data in the DataSet which are required for the Reapeater.

Sunday, January 18, 2009

CSS for TextBox

Dev Palmistry

How to make css for TextBox :

To link a document to a CSS text file (say, styles.css), place a link tag in the document’s header:

LINK REL=”STYLESHEET” TYPE=”text/css” HREF=”styles.css”

The href attribute tells the web browser where the style sheet file (style1.css) can be found, in the same way that the href attribute is used in an anchor to point to the destination file (e.g. Home).

The rel="stylesheet" and type="text/css" parts of the link tag tell the browser what kind of file is being linked to, and how the browser should handle the content. You should always include these important attributes when linking to a .css file.

In page.aspx:

asp:textbox id="txbTest" CssClass="textbox"

In Styles.css:

font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 9px;

Sunday, January 11, 2009

Asp.Net , C# and Sql One Line Question Ansewr

In One line answer Of Dot Net Question

Qut: Waht is Data Binding ?

Ans : Data Binding involves fetching the data from database and binging each row and colums from the data to the row and columns in control.

Que : Waht is the tag is used for the data bainding ?

Ans : Ans : The special <% # and %>tags delimit the data binding exprission .

Qut : Is every control has databind() method ?

Ans : Yes , It is a method of base control class used by both the web and html control .

Qut 4 : What is the advantage of Data binding ?

Ans : The advantage is that it helps to you achive a clear seperation b/w your control and code your code in a wev page.

Qut : What happen when we forget to call control's DataBind() method ?

Ans : If we forget to call the control's DataBind() method , the control will remain empty , and the information will not appear on the page.

Qut 6 : Specially for which control Data binding is sesigned ?

Ans : The control like DataGrid , GridView , Datalist , Detail View , FormView and Repetar is designed for data binding .

Qut 7 : Which property and mathod are used by control for data bainding ?

Ans : Controls that support databinding exposed a property named :

DataSource (Property)

DataBind (Method)

Qut 8 : Is it possible to bind data to the text box ?

Ans : Yes

Qut 9 : What is .NET Framwork ?

Answer : The .Net Framework is a managed , type safe environment for developing and executing appications.

Qut 10 : What is the main two compaonat of the .Net Framework ?

Ans : Comman Language Runtime (CLR)

Class Libraries

Qut 11 : What is the CLR ?

Ans : CLR (Commann Langguage Runtime) is described as the "Execution Engine" of the .net .

Qut 12 : What is class libraries ?

Ans : Class libraries consists of lots of prewritten code . The code for all the elements like forms , controls

actualy comes from the class library .

Qut 13 : What is CLS (Comman Language Specification) ?

Answer : The cls describe a set of rules (features) that different language have in common .

Qut 14 : What is Web services ?

Ans : Web Services are the applcation that run on web surver and communicate with othe application . It uses

different or seried of protocols to responds to different request. The protocols are UDDI , WSDL , SOAP , XML , Http

, Smtp .

Qut : 15 : What is the Meaning of UDDI , WSDL , SOAP ?

Ans : UDDI (Univarsal Discovery and Description Language)

WSDL (Web Services Description Language)

SOAP (Simple Object Access Protocol )

Qut 16 : What is managed code ?

Ans : Managed code is IL (Intrmidiate Language ) which C # compiler produce . It is not machine code taht runs

directly . But Intermitiate code (IL) that is stored in the Assembly and handled by CLR (Comman Language Runtime).

Qut 17 : What is Unmanage Code ?

Ans : This code is machine executable code that execute directly without being manupulate by CLR (Comman Language


Qut 18 : Is IL (Microsoft Intermidiate Language) code is mannaged code ?

Ans : Yes .

Que : 19 : Is managed code is plateform Indepandent ?

Ans : yes .

Que : 20 : What is the advantage of Managed Code (IL) ?

Ans :Managed code has a big advantage over unmanaged code in terms of plateform depandancy .

Que 21 : What is Assembly ?

Ans : Assemby is self describing instalation unit . It may consists of more than one dll or exe . Assemby contan

manifist. Manifeat cantain metadata . All the Assemblies contan - the definition of tupes , version information of

version , meta-data , and manifiest .

Que 22 : How many Types of Assembly >

Ans : Assemby are two types :



Que 23 : What is the namespaces ?

Ans : A namespace is collection of differnt classes .

All the C# application are developed by using classes from the .Net System namespace .

All other namespaces are based on the This System namespaces .

Que 24 : What is view ?

Ans : A View is a virtual tables , which consites of a subset of columns from one or more tables .

Que 25 : What is the advantage of View ?

Ans : View is used for data security reasion , when view is used to manipulate table data , the underline base table
will be complitely invisible . This will give the label of data security .

Que 26 : How many types of view ?

Ans : There differnt types of view :

Read-Only View

Updatable View .

Que 27 : Can we use order by clause when creating view ?

Ans: The Order by clause can not be used while creating a view .

Que 28 : Can record be Updated or deleted with the help of view ?

Ans : Yes , The user can update and deldte records with the help of view even if the primary key columns and NOT

NULL columns are execluded from the view definition (On single table) .

Que 29 : Can record be inserted with the help of view ?

Ans : Yes , It user wants to insert record with the help of view , then the Primary keyb columns and all the NOT

NULL columns must be included in the view . With some exception , we can also parform database operations INSERT ,

UPDATE and DELETE with single - table database views .

Que 30 : What is the syntex of destryin the view ?

Ans : The Drop viw command is used to remove a view from a database .

Drop view vw_client .

Que 31 : Why View is called Virtual ?

Ans : A view is not stored as phisical table , only its definition is stored . For this reasion , view are called

virtual table .

Que 32 : What is the two reasion for using the view ?

Ans : There are main two reasion to use view :



Que 33 : What is the FindControl() ?

Ans : Static page.findControl() method , which search the entire page for control with the ID we supplied .

Que 34 : Every Codebehind class is explictly derived from ?

Ans : Every codebehid class is explictly derived from :

System.Web.UI.Page class .

Ans 35 : What is Page Class ?

Ans : All the forms are actually insance of the Asp.Net Page Calss , which is found in the System.Web.UI.Page class.

Que 36 . What is the Stored Procedure ?

Ans : Stored Procedure is Precomplied database object . Precomplied means that procedure is comlied beforhand and is

readily avalable for execte. As a result , time is not spent at all in parsing and compling the procedure again.

Que 37 : What is the adwantage of Stored Procedure ?

Ans : Advantage of S.P. :

Improve performance

Reduce Network Congetion .

Que 38 : How S.p. Improve Performance ?

Ans : Application do nat have to compile the procedure over again and again .

Que 39 : How S.P. Reduce Network Congetion ?

Ans :

Que 40 : How many maximum number of parameters are allowed in a S.P. ?

Ans : 1024 .

Que 41 : How S.P. send and reveive data ?

Ans : A S.P. recives and send data through the folloeing :

Input parameters

Output parameter

Return code

Que 42 : How many types of S. P. ?

Ans : Vaires types of s.p. are :

User Defined

System Defined

Temprorey (prefix with # symble)


Que 43 : Give the list of object which can not be created within a stored procedure (restriction taht apply on S.P.) ?

Ans : The following object can not be created within a stored procedure :






Que 44 : What are Trigar ?

Ans : Triggers are special type (kind) of stord procedure that gets executed automatically when an INSERT , UPDATE

and DELETE statement (operation) takes place on a table .Trigaers are invoked (fired) automatically by Sql Server

when any modification statement is issued .

Another Definotion of Triggers :

A trigger is always defined on a table , and is said to be fired whenever the data in the underline table is

affected by any of the Data Manulation Language (DML) statement - INSERT , UPDATE and DELETE.

Que 45 : How many trigger can be define par table ?

Ans : In Sql 6.5 you could define only 3 triggers per table , one for Insert , one for Update and one fpr Delete.

Foom Sql Server 7.0 onwords , this restriction is gone ,and you could create multiple triggers per each action .

Que 46 : What is the difference between S.P. and Trigeres ?

Ans : It can't be explicitly invoked or executed as in the case of S.P. . It is invoked automatically (implicitely)

Que 47 : How many level triggers are nested ?

Ans : Triggers are nested 32 levels .

Que 48 : Why triggers are used ?

Ans :Triggers can be used to enforce the business rules and data intigrity . It privent incorrect , unauthorized or inconsistant change data .

Que 49 : What is the Characteristics of the triggers ?

Ans : Itv can only be associated with table .

It can not retun data to the user .

Que 50 :Can triggers be defined on temprory table or view ?

Ans : It can not be defined on a temprorary tabales or views . However , a triggers can reference temprorey tables and views .

Que 51 : What are cursor ?

Ans : Cursor allow row by row processing of The resultsets.

Que 52 : How many types of cursors ?

Ans : Cursor are 4 types :

Que 53 : What are disadvantage of cursor ?

Ans : Eatch time you fetch a row from the cursor, it result a roundtrip ,where as normal SELECT statement (query) makes only one roundtrip ,however large the large resultset is. Cursor are also castoly because they requre more resources and tempory storage.

Que 53 : What is roundtrip ?

Ans : When a user submit a page , the page is posted back to the web server for server-side processing. After the processing the processing is done on the web server ,the page is sendback to the client. This sequece is called round trip.

Que 54 : What is directive ?

Ans : A directive specify how an Asp.Net page is complied .

Que 55 : What is native code ?

Ans : Native code is the code that has been complied to CPU specific machine language.

Que 56 : How does assembly versoning in .Net prevent DLL hell ?

Ans : .Net allows assemblies to specify the name and the version of any assemblies they need to run .

Que 57 : What is cookies ?

Ans : Cookies are small text file. A small amount of inforamation sent by web server to the web browser , saved by browser, and sent back to the server.

Que 58 : What is the order of event in yoru page ?

Ans : Init ()
Load ()
Prerender ()

Unload ()

Que 59 : How can we kill a user sessoion ?

Ans : call session.abandan .

Que 60 : What is the DLL hell problem ?

Ans : 1. Copy the dll (C:\my COM /calc.dll)
2.Register it (regsve32 )
3. Registry entry ( OS - it is part of OS )

Que 61 : What is the reasion of DLL hell ?

Ans : 1.Identy (GuID)
2.Registry Intraction
3.Every COM is titely coupled with OS.

Que 62 : What is the .Net Solution of DLL hell ?

And : 1. No registary intruction (Only copy and pest ) . It never goed to registory .
2..Net assemblies are loosley coupled whit OS .
3. Identity (Name ,Culture, Strong Name, Version) .

Que 63 : What is parser error ?
Ans : Its basically syntax error in your aspx page .

Que 64 : What is caching ?

Ans : Caching is technique of storing an in-memory copy of some information that is expencive to create .

Que 65 : How many attribute in form tag ?

Ans : < method="" action="">
There are two attribute of Form tag :

Que 66 : What is the Method ?

Ans : Method is way to sent the data . There are two option - Post and Get .

Que 67 : What is the Action ?

Ans : Action is used to specify the address where you want to send the data .

Que 68 : What is the use of using GET method ?

Ans : We can use get method when we have to Use as a book mark .

Que 69 : How many character are show in URL by Get method ?

Ans : Limited no of character ( 256-249 ) .
Limited no of character.

Que 70 : Which machanics is used in .Net POST or GET ?

Ans : It is POST method .

Que 71 : What is the advantege of POST method ?

Ans : Data is never visible in the URL .
Post method is slower .
Post method has huge data .

Que 72 : What does the URL ?

ANS : URL loads your data .

Que 73 : What the meaning of Page Navigation ?

Ans : The page navigation means going from one page to another page .

Que 74 : Why used POST rather than GET in Asp.Net ?

Ans : Since GET shows only limited no. of character in the url about 256. and these queries add more than 256 character and there is no problem in POST method becaues Post METHOD has huge data .

Que 75 How : How can u create an event handler ?
Ans : Double click the Button to create a new event handler method .

Que 76 : Waht does Asp.Net when we use Server control at runtime ?
Ans : ASP.NET generates HTML code for you at runtime when you use server controls.

Que 77 : What is The ID of Server control ?
Ans : The ID is what you use in the C# source code behind .cs file to reference a control on a web form.
When you drag a control onto the web form, the IDE creates a default ID for your control .

Que 78 : What is Event Handler Method ?
Ans :An event handler method is a special type of Method in an ASP.NET web page that defines the actions that will occur when a particular event occurs.

Que 79 : What is event driven programming model ?
Ans : ASP.NET uses an event driven programming model. This means that in order for code to run, an event must occur that triggers or tells ASP.NET to run an event handler Method.

Que 80 : Explane Button1_Click ?
Ans : We saw that if you are in the Design view for a web form and you double click on a Button control, Visual Web Developer will automatically generate an event handler Method called Button1_Click. Basically an empty Method is
generated and Visual Web Developer lets you put whatever code you want into that event handler. Notice the naming
convention that Visual Web Developer when it generates the event handler Method. The first part of the name is the
ID for the server control: Button1. The second part of the name an underscore appended with the event type: Click.

Que 81 : Give example of Event Handler Method ?
Ans : event handler Method called Button1_Click .

Que 82 : What is Requred field validation ?
Ans : ASP.NET offers the RequiredFieldValidator control to ensure that mandatory fields are filled in.(i.e. fields that must be filled out)

Que 83 : What is benifit of VAlidation Control ?
Ans : Validation controls do not require any coding, thus saving time performing redudant tasks.

Que 84 : What are the property of RangeValidator control ?
Ans : ASP.NET offers the RangeValidator control to ensure that fields follow range rules.
The ErrorMessage property sets what error text will be displayed in case the validation fails. The MaximumValue property sets the largest possible value in your validation rule that is acceptable.
The MinimumValue property sets the smallest possible value in your validation rule that is acceptable
Type property lets the validator know what type of data will be validated: String, Integer, Date, etc.

Que 85 : Why we use The ControlToValidate property ?
Ans : The ControlToValidate property sets which server control to examine at runtime to see if it follows the rule.

Que 86 : What is ccs. ?
Ans : Cascading Style Sheets are text files with a .css extension.
These files contain a list of styles(style means font , size and colour ) that are defined for an application.

Que 87 : What is the style ?
Ans : A style is a descriptor that defines how an object in a web page should look and how it should be layed out within the page.

Que 88 : Give one exp of style ?
Ans : For example, with a style you can define that the font size for text box should be 12 point and it should be left aligned. Applications typically contain many styles for various objects in a web application .

Que 89 : What is the Redirect Method ?
Ans : ASP.NET gives you access to a special object called the Response object. The Response object contains a method called Redirect that you can use to perform the redirection to another web page. You should pass the name of the web page to the Redirect method as a string parameter.
This method transfers the user to another page in the application or to a different web site.

Que 90 : What is the Redirect means ?
Ans : A redirect simply means you are sending a message to the browser, telling it to visit a different web page.

Que 91 : What is the session object ?
Ans : There are also situations where you may want to store information in the Session that is shared among ALL web
pages in your ASP.NET application.
The Session object is similar to a Dictionary object as it contains key/value pairs.

Que 92 : Give the example of Session state ?
Ans : In the example for this lesson, I setup a web form called Page1 that contains some TextBox controls to allow
the user to type their name and credit card information. When the user clicks the Next button, I store the
information entered into the Session object and redirect the application to another web form called Page2 (which is
a confirmation page).
Session["FirstName"] = txtFirstName.Text; Session["LastName"] = txtLastName.Text; Session["CreditCardNumber"] = txtCreditCardNumber.Text; Session["ExpirationDate"] = txtExpirationDate.Text; Response.Redirect("Page2.aspx");
Session["FirstName"] = txtFirstName.Text;Session["LastName"] = txtLastName.Text;Session["CreditCardNumber"] = txtCreditCardNumber.Text;Session["ExpirationDate"] = txtExpirationDate.Text;
Response.Redirect("Page2.aspx");On the Page2 confirmation page, I read back the variables from the Session object and display them on the web page.
txtFirstName.Text = Session["FirstName"].ToString(); txtLastName.Text = Session["LastName"].ToString(); txtCreditCardNumber.Text = Session["CreditCardNumber"].ToString(); txtExpirationDate.Text = Session["ExpirationDate"].ToString();
txtFirstName.Text = Session["FirstName"].ToString();txtLastName.Text = Session["LastName"].ToString();txtCreditCardNumber.Text = Session["CreditCardNumber"].ToString();txtExpirationDate.Text = Session["ExpirationDate"].ToString();

2 .
5 .
6 .

Que 93 : Introduction of data type ?
Ans : This is important to understand because although the syntax of the C# language is different than VB.NET and
others, the data types used are the same. Every time you declare a variable type in C# like “int” for example, you are really declaring a .NET Framework type called Int32, which is a large 32 bit signed integer number.

Que 94 : What is the meaning of // ?
Ans : The // tells C# that you are putting a comment into the program. A comment is simply notes or comments that are ignored by the compiler .

Que 95 : What are the methods ?
Ans : Methods are blocks of code that perform some actions and can return back a result . Methods are also called Functions or Procedures in other languages.

Que 96 : What will happen when we will not use return in method ?
Ans : Since I declared that my Method will return a number, it is mandatory that I have a “return” statement in my
Method. If I don’t put a “return” statement, the source code compiler will throw an error.

Que 97 : Is every thing is built around Classes in c# ?
Ans :In C#, almost everything is built around Classes, even some of the language data types such as String, which is actually a Class called System.String.

Que : How to call a class ?
Ans : In order to call a Class you first have to Instantiate an Object of the Class. This terminology means that you have to declare a variable with the type set to your Class name.

Que 98 : What is DataSet ?
Ans : A DataSet is a set of rows that can hold data in memory.A DataSet has columns, just like a database table. The DataSet was purposely designed to be disconnected from the database.

Que 99 : Why we use System.Data.SqlClient namespace.?
Ans : That namespace contains connection and query oriented classes.

Que 100 : Waht is the use of SqlConnection class ?
Ans : There is a class called SqlConnection that allows you to open a database connection to SQL Server.
Que 101 : For which purpose SqlDataAdapter class ?
Ans : The SqlDataAdapter class is responsible for executing the queries.

Que 102 : What is the use of " using " block ?
Ans : I created a special block of code called a “using” block with open and closed curly braces. The using statement is used in situations where you want .NET to automatically close a resource when you are finished using it.

Que 103 : What does the "using " block ?
Ans : The using statement block will make sure that the dbconn object is available until the closed curly brace. After the closed curly brace, the dbconn object isn’t available for use anymore.

Que 104 : What is the method of SqlDataAdapter ?
Ans : Fill is the method SqlDataAdapter .

Que 105 : What is the meaning of this - dbadapter = new SqlDataAdapter("select * from Customer", dbconn);
Ans : Inside the using statement, I first instantiate the SqlDataAdapter object and call the constructor method.
The constructor takes two parameters: a string containing the SQL query you want to execute and an SQLConnection
object (dbconn) that tells .NET which database to execute against.

Que 106 : What is the meaning of this - dbadapter.Fill(dbdata);?
Ans : I call a special method of the SqlDataAdapter object called Fill. Fill allows you to take the results of the query and store them in a DataSet object which is dbdata in my example.

Que 107 : Explane me thies lines accordingly to the c# concept ?
DataSet dbdata = new DataSet();
dbadapter = new SqlDataAdapter("select * from Customer", dbconn); dbadapter.Fill(dbdata);
Ans :

Que 108 : What is the meaning of thies two lines ?
Ans : Once I have the DataSet object populated with data from the database, there are many things that I can do with it. In this example, I am displaying the data in an ASP.NET GridView (similar to an HTML table tag) control. In
order to achieve this, I have to perform data binding. In .NET data bound controls are basically server controls
like a GridView that have a DataSet object assigned (bound) to them. Once a DataSet is bound to a server control,
the server control (e.g. GridView) can display the data that is in in the DataSet on the web page. For a GridView
control, this is very easy and only takes two lines of code. First you have to assign the GridView’s DataSource
property to a DataSet object that contains data. Then you call the GridView’s DataBind method to let ASP.NET know
that you want to display the data.

Que 109 :Why we do AutoGenerateColumns property of the GridView to False. ?
Ans : Normally when you use a GridView control, it will show all the columns in the associated DataSource. The GridView also displays the column names as the header for the grid on the web page.
In a real world scenario, you probably are going to need more control over what is displayed in your grid. The way
to achieve this is to set the AutoGenerateColumns property of the GridView to False.
When you do this, it lets ASP.NET know that you are going to manually define how you want the data displayed in your grid .

Que 110 : What is meaning of BoundField ?
Ans : A BoundField means that you are creating a display field that is “bound” to a column in the DataSource.

Que 111 : Waht does HeaderText property ?
Ans : The HeaderText property gives you the ability to control what shows up as the header for each grid column.
Notice that even though my query is returning more than two columns from the database table, I am only showing two
of them on the web page.

Que 112 : Why Debugging and Tracing are used ?
Ans : "Debugging and Tracing" feature are used for sorting and fixing errors .

Que 113 : What is the method used in Classic Asp ?
Ans : In classic ASP, using Response.Write method we can display an error message .

Que 114 : Whaat is the drawback of using Response.Write method in asp ?
Ans : Although it is easy to use, it has some drawbacks. Before deployment we have to remove or comment out all those Response.Write statement wherever we have used in the application. We cannot forget to remove or comment out any such statement that can be visible to end user/client.

Que 115 : What is round trip ? and it is alwaysing confusing for me ?
Ans : To Understad Round trip by one example you can understand it properly . By Using Response.Redirect() and
Server.Transfar(). Response.Redirect requires a round trip between the browser and the server, but allows the user
to see the new URL in the browser address bar.Server.Transfer is a quicker approach in that ASP.NET simply loads the
specified page without the round trip. As a result, the browser’s address bar is not changed.

Que 116 : Why we inherite System.Web.UI.Page class in our cs file ?
Ans : By using this we can directly use the page class objects like - 1. Session
2. Application
3. Cache
4. Request
5. Response
6. Server
7. User
8. Trace

Que 117 : What is the meaning of Credintials ?
Ans : Credentials means loging and password .

Que 118 : What is the IsPostBack ?
Ans : IsPostBack is the property of the page ,IsPostBack gets a value indicating whether the page is being loaded in response to a client postback, or if it is being loaded and accessed for the first time .
Que 119 : What is the IsValid ?
Ans : IsValid is the property of the page , IsValid gets a value indicating whether page validation succeeded .

Que 120 : What is the EnableViewState ?
Ans : EnableViewState is the property of the page , gets or sets a value indicating whether the page maintains its view state .

Saturday, January 10, 2009

Garbage Collection

Garbage Collection

When you initialize a variable using the new operator, you are in fact reserving some space in the heap memory. The memory is "allocated" for the variable. When that variable is no longer needed, such as when your program closes, it (the variable) must be removed from memory and the space it was using can be made available to other variables or other programs. This is referred to as garbage collection. In the past, namely in C/C++, this was a concern for programmers because they usually had to remember to manually delete such a variable (a pointer) and free its memory.

The .NET Framework solves the problem of garbage collection by "cleaning" the memory after you. This is done automatically when necessary so that the programmer doesn't need to worry about this issue.


1.True foundation of events is delegates.

2.Events are declared using delegates

3.There are two important terms with respect to events. The event source and the event receiver

4.The object that raises the event is called event source and the object that responds to the event is called event receiver. The communication channel between an event source and an event receiver is the delegate .

5.What is Delegate ?

Ans: Delegates act as an intermediary between an event source and an event destination.

Technically, a delegate is a reference type used to encapsulate a method with a specific signature and return type.

You can encapsulate any matching method in that delegate.

To be even precise delegates are similar to function pointers.

They can be called as type safe function pointers.

Unlike function pointers, delegates are object-oriented and type safe.

A delegate class used as an intermediary between an event source and event receiver is called an event handler.

Delegates can be considered as 'function pointers' which is used to represent or invoke functions.

A delegate in C# is similar to a function pointer in C or C++.

A delegate in C# allows you to pass methods of one class to objects of other classes that can call those methods.

You can pass method m in Class A, wrapped in a delegate, to class B and Class B will be able to call method m in class A.

The concept of delegate was introduced in Visulal J++ and then carried over to C#.


What is the Function Pointer ?

Answer : A function pointer is a variable that stores the address of a function that can later be called through that function pointer.

This is useful because functions encapsulate behavior.

For instance, every time you need a particular behavior such as drawing a line, instead of writing out a bunch of code, all you need to do is call the function. But sometimes you would like to choose different behaviors at different times in essentially the same piece of code.

A function pointer is a type of pointer in C, C++,

In programming languages like C, function pointers can be used to simplify code by providing a simple way to select a function to execute based on run-time values.

You can use them to replace switch/if-statements, to realize your own late-binding or to implement callbacks.

One aspect in the case of late-binding is runtime

Function Pointers are pointers, i.e. variables, which point to the address of a function. You must keep in mind, that a running program gets a certain space in the main-memory. Both, the executable compiled program code and the used variables, are put inside this memory. Thus a function in the program code is, like e.g. a character field, nothing else than an address. It is only important how you, or better your compiler/processor, interpret the memory a pointer points to.

Important note: A function pointer always points to a function with a specific signature! Thus all functions, you want to use with the same function pointer, must have the same parameters and return-type!

Programmers often need to implement callbacks. I will discuss the fundamentals of function pointers and show how to use them to implement callbacks.

A callback function is one that is not invoked explicitly by the programmer; rather the responsibility for its invocation is delegated to another function that receives the callback function's address.

Example Uses of Function Pointers

Functions as Arguments to Other Functions :

If you were to write a sort routine, you might want to allow the function's caller to choose the order in which the data is sorted; some programmers might need to sort the data in ascending order, others might prefer descending order while still others may want something similar to but not quite like one of those choices. One way to let your user specify what to do is to provide a flag as an argument to the function, but this is inflexible; the sort function allows only a fixed set of comparison types (e.g., ascending and descending).

A much nicer way of allowing the user to choose how to sort the data is simply to let the user pass in a function to the sort function. This function might take two pieces of data and perform a comparison on them. We'll look at the syntax for this in a bit.

Callback Functions :

Another use for function pointers is setting up "listener" or "callback" functions that are invoked when a particular event happens. The function is called, and this notifies your code that something of interest has taken place.

Why would you ever write code with callback functions? You often see it when writing code using someone's library. One example is when you're writing code for a a graphical user interface (GUI). Most of the time, the user will interact with a loop that allows the mouse pointer to move and that redraws the interface. Sometimes, however, the user will click on a button or enter text into a field. These operations are "events" that may require a response that your program needs to handle. How can your code know what's happening? Using Callback functions! The user's click should cause the interface to call a function that you wrote to handle the event.

To get a sense for when you might do this, consider what might happen if you were using a GUI library that had a "create_button" function. It might take the location where a button should appear on the screen, the text of the button, and a function to call when the button is clicked. Assuming for the moment that C (and C++) had a generic "function pointer" type called function, this might look like this:
void create_button( int x, int y, const char *text, function callback_func );

Whenever the button is clicked, callback_func will be invoked. Exactly what callback_func does depends on the button; this is why allowing the create_button function to take a function pointer is useful.

6. An event in C# is a way for a class to provide notifications to clients of that class when some interesting thing happens to an object.

7.The most familiar use for events is in graphical user interfaces; typically, the classes that represent controls in the interface have events that are

notified when the user does something to the control (for example, click a button).

8.Events are declared using delegates

9.Clicking the button is normally referred to as an 'Event' and all the associated functions that are called as a result of an event as 'Event Handlers'

10.Events are an important building block for creating classes that can be reused in a large number of different programs

11. Event handler is a method that has the same signature as the event and this method is executed when the event occurs.

12.To define an event you need first to define a delegate that contains the methods that will be called when the event raised, and then you define the event

based on that delegate.

13.D.What is Events ?

Event is the part of even-driven progarming language.It is part of Grafical User Interface(GUI) .

Events are handled by Delegate.

Events has two arguent: first is object and second is EventArgs

Object is reconized which button is being clicked because there are lots of buttion in the page. Object parameter recognize source of the event. And on the


In general , every code which we write is placed in the event. like page_load event or button click event and when event is fired the code is executed.Every

code is placed in the event that why it is said is event driven.And when ever we click button the event is fired and the code is postback(submit ) to

the server.And this every develor knows wery well but how button do this does not know. For knowing we have to knnow about Delegates and Eventts. Events

occures on the page. When a user interacts with a GUI control (e.g., clicking a button on a form), one or more methods are executed in response to the

above event.

14.Event Handlers in C# :

An event handler in C# is a delegate with a special signature, given below.

public delegate void MyEventHandler(object sender, MyEventArgs e);

The first parameter (sender) in the above declaration specifies the object that fired the event.

The second parameter (e) of the above declaration holds data that can be used in the event handler.

The class MyEventArgs is derived from the class EventArgs.

Dev said : Event Handler is a method where we write to code.

event handlers (methods with the same signature as that of the delegate declaration).

Still, it is better to know what is going on under the hood.

15.DEV : i am still confused how event and delegates are related , i only understand that Delegates are the that pass methods of one class to object of other

class taht call those methods.I too undersatand about the Event Handler, Event Handler is method with two parameters where we place our code to execute.

16. 'notified' (this simply means that all the event handler functions are invoked).

17.We can now look at how events are implemented in C# and how it is associated with event handlers.

18.DEV UNDERSTAND : fOR evnet three things are impartant :

First Event Handlers function -

public void onButtonClick (object source, int clickCount) {
//Define the actions that should be performed.

Second Delegates -

The delegate declaration will be as follows:

public delegate void ButtonEventHandler(object source, int clickCount)

where ButtonEventHandler is the delegate name.

Third is Event -

The event declaration will be as follows:

public event ButtonEventHandler ButtonClick;

The event declaration should have the keyword 'event' followed by the delegate type.

DEV SAID : We can see the paramerter of Event Handler Function and Delegates are the same - object sender and int count .

After taht the next step is the associating the Event handler function (onButtonAction) with the event (ButtonClick).

This is to be done because the ButtonClick event should know about the functions that are to be executed when the event is triggered

The operator += is used to achieve this as shown in the following code:

b.ButtonClick += new ButtonEventHandler(onButtonAction);

Here, b is an instance of the class Button. (Also, note that the onButtonAction should have the same parameter and return types as ButtonEventHandler


The operator += is used to achieve this as shown in the following code:

b.ButtonClick += new ButtonEventHandler(onButtonAction);

Here, b is an instance of the class Button. (Also, note that the onButtonAction should have the same parameter and return types as ButtonEventHandler


Now consider that the event is triggered. This can be done by the user or another process. In our case, the event is triggered when a user clicks on any of

the buttons. On doing this, all the associated functions (onButtonAction in the current context) of ButtonClick event should be executed. This can be

performed using the following code:

ButtonClick(this, count)

The parameters of ButtonClick should match with the delegate type (ButtonEventHandler).

19. How Event works?

Whenever an event is defined for a class, the compiler generates three methods that are used to manage the underlying delegate:

add_ :
this is a public method that calls the static Combine method of System.Delegate in order to add another method to its internal invocation list. This method

is however not used explicitly. The same effect is achieved by using the += operator as specified before.

remove_ :
this is also a public method that calls the static Remove method of System.Delegate in order to remove a receiver from the event's invocation list. This

method is also not called directly. Its job is done by the "-=" operator.

raise_ :
a protected method that calls the compiler generated Invoke method of the delegate, in order to call each method in the invocation list.

20.Dev Said : Signature is impartant for Delegates. It should match whith the method or function which is being passed.

The Event model in C# finds its roots in the event programming model that is popular in asynchronous programming. The basic foundation behind this programming model is the idea of "publisher and subscribers." In this model, you have publishers who will do some logic and publish an "event." Publishers will then send out their event only to subscribers who have subscribed to receive the specific event.

In C#, any object can publish a set of events to which other applications can subscribe. When the publishing class raises an event, all the subscribed applications are notified. The following figure shows this mechanism.



The following important conventions are used with events:

Event Handlers in the .NET Framework return void and take two parameters.
The first paramter is the source of the event; that is the publishing object.
The second parameter is an object derived from EventArgs.
Events are properties of the class publishing the event.
The keyword event controls how the event property is accessed by the subscribing classes.

What is Event ?

An event is a placeholder for code that is executed when the event is triggered, or fired. Events are fired by a user action, program code, or by the system.

From a more formal perspective—and the C# point of view—an event is an object member, specifically a method

This Link Wolud Explane All :

Friday, January 9, 2009

Commanl Language Specfication (CLS)

FrameworkSDK folder (usually at C:\Program Files\Microsoft Visual Studio .NET\FrameworkSDK\Tool Developers Guide\docs) contains the Common Language Infrastructure (CLI) specification.

The Common Language Specification (CLS) defines the minimum things that a language must support to be compliant.

The CTS defines the common data types used by

The CTS tells you how to represent characters and numbers in a program.

The CLS represents the guidelines defined by for the .NET Framework.

These specifications are normally used by the compiler developers and are available for all languages, which target the .NET Framework.

It will contain set of rules in all the Dotnet Languages

CLS is a subset of CTS.

These specifications are normally used by the compiler developers and are available for all languages, which target the .NET Framework.

ASP.NET - Events

Dev Palmistry

An Event Handler is a subroutine that executes code for a given event.

The Page_Load Event

The Page_Load event is one of many events that ASP.NET understands. The Page_Load event is triggered when a page loads, and ASP.NET will automatically call the subroutine Page_Load, and execute the code inside it:

The Page.IsPostBack Property

The Page_Load subroutine runs EVERY time the page is loaded. If you want to execute the code in the Page_Load subroutine only the FIRST time the page is loaded, you can use the Page.IsPostBack property. If the Page.IsPostBack property is false, the page is loaded for the first time, if it is true, the page is posted back to the server (i.e. from a button click on a form):

Tuesday, January 6, 2009

How many types of Web Sites .

Since i am in the field of Web Site development . When i started developing website i dont know how many types of web sites and what is the purpose of these websites .We just started developing the websites. Gradually i come to know that how many types of websites and what is the purpose of all these websites.

There is are different types of websites and each have it own impartance.

A micro site
A mini site
A content site
A blog
A forum site
An ecommerce site

But today i would like to discuss two types of wevsites :
Firest is Contant Base Website
Second is E-commerce Website

A Contant Site : A Contant Site filled with contant.The contant would be in the form of informational articles.The contant would in the form of intersting videos(think YouTube),audio interviews, how to screencasts, image collection (as in flicker)

Example of Contant Site :

What are the contants: Educational, informative ,Intertaining
Although you can create one website about anything and everything, it’s better practice to specialize in a certain niche. So, you could build a site about beds and have articles about beds, videos on how to choose the right bed, images of different types of beds … If you absolutely need to write about chairs as well, you could easily just start a separate site about chairs.
What is the purpose of Building Contant Sites or Why we build Contant Site :There are some reasions - Attract and Retain an audiance : A website filled with useful, valuable, informative, educational or just plain entertaining content is one of the best ways to attract an audience and make them stay longer. And if you can add more content to your site on a regular basis, they will keep coming back over and over again.

Build a Reputation : It is much easier to build anonline reputation with a contant site than anyother type site of site. When people realise that you are constantely offering great quality contant, you will quickly be known as some one who they can trust whom they would tern to for information in your site.This reputation will go a long way in attracting even more traffic through word of mouth. And, of course, once you have a good reputation, it is much easier for you to profit from affiliate product recommendations and even your own products.

Entice search engine spiders : A well thought out content site is a powerful magnet for search engines. It is a fact that search engines cannot resist a site filled with great content. It is easier to rank higher in the search engines with a content site than a mini site. You can create unlimited number of content pages that can target a different keyword phrase each. This will give you more opportunities to be “seen”.

Generate incoming links : When you have a good quality content site, people are more likely to want to link to you. And often without you asking them to. More links to your site will push your rankings even further up the search engine results pages which in turn will drive even more traffic to your site.

Monetize with multiple streams of income

Another great thing about a content site is that there are multiple ways you can monetize it. You can earn affiliate income by linking to affiliate products in your content. You can promote your own product. You can sell ad space. Or you can participate in ad programs such as Google Adsense or Yahoo Publisher Network and earn some money each time someone clicks on the ads.

Secont is E-commerce Websites :
E-commerce websites allow shop owners to sell their products online. Users can browse the website, and add various products to their carts. They then can checkout by entering their shipping and billing information. The shipping information is send to you and their credit card is instantly charged. The funds are then deposited into the shop owners' bank account. The shop owner then sends the user the ordered products. This is the same process used at most major online stores, such as and

With customizable shipping and tax rates, the shop owner is given much flexibility on how he or she would like their online shop to work. With almost unlimited products, shop owners can sell many varieties of products.

With more than 700 million potential buyers on the internet, the Internet is an opportunity that cannot be passed up by store owners. To view an example of an e-commerce website, click here. Once you have viewed our example, request a free quote, and we will contact you within 48 hours.

This project is based upon Online shopping (eCommerce Solutions)
When a online shoppers (customers) click on the buy button on the web site, they are taken through a secure shopping cart and checkout process (hosted on Payment Online secure servers) where credit card transaction information can be entered.

After processing the credit card online, authorization responses are then returned to your new online customers in "real-time" and a confirmation of sale is emailed to Admin and customers. You can then ship the goods to your customers.

Customers can track there all the transactions and their relevant history. They can buy online gift vouchers that easily redeems by this application

Admin easily to calculate the daily orders and generate daily, weekly, monthly basics reports.