protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
string sName = "Tibbet";
string sBrand = "Kohinoor";
string sDescription = "For menz only";
Response.Redirect(string.Format("Default.aspx?qs1={0}&qs2={1}&qs3={2}", sName, sBrand, sDescription));
}
}
From second page we can read the value like:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if ((Request.QueryString["qs1"] != null && Request.QueryString["qs2"] != null) && Request.QueryString["qs3"] != null)
{
string sName = Request.QueryString["qs1"];
string sBrand = Request.QueryString["qs2"];
string sDescription = Request.QueryString["qs3"];
Response.Write(sName+"");
Response.Write(sBrand + "");
Response.Write(sDescription);
}
}
}
ASP.NET is a web application framework developed and marketed by Microsoft to allow programmers to build dynamic web sites, web applications and web services. It was first released in January 2002 with version 1.0 of the .NET Framework, and is the successor to Microsoft's Active Server Pages (ASP) technology. ASP.NET is built on the Common Language Runtime (CLR), allowing programmers to write ASP.NET code using any supported .NET language.
Friday, June 24, 2011
Wednesday, June 22, 2011
Implementing Caching in ASP.NET
What is Caching?
Caching is a technique of persisting the data in memory for immediate access to requesting program calls. Many in the developer community consider caching as one of the features available to improve performance of Web applications.
Why Caching?
Consider a page that has list of Employee name, contact numbers and mail-Ids of existing employees of a company on an intranet accessible by all employees. This is very useful information that is available throughout the company and could also be one of the most accessed pages. The functionality of adding, updating or deleting is usually less intensive compared to more transaction-based systems like Purchase ordering, Voucher creation etc. Now in a normal scenario the process of querying database for each request is not cost-effective in terms of server resources, hence is lot better to cache or persist the data to avoid this costly loss of resources.
for full description
Caching is a technique of persisting the data in memory for immediate access to requesting program calls. Many in the developer community consider caching as one of the features available to improve performance of Web applications.
Why Caching?
Consider a page that has list of Employee name, contact numbers and mail-Ids of existing employees of a company on an intranet accessible by all employees. This is very useful information that is available throughout the company and could also be one of the most accessed pages. The functionality of adding, updating or deleting is usually less intensive compared to more transaction-based systems like Purchase ordering, Voucher creation etc. Now in a normal scenario the process of querying database for each request is not cost-effective in terms of server resources, hence is lot better to cache or persist the data to avoid this costly loss of resources.
for full description
Labels:
Asp.net
Monday, June 20, 2011
website icon
1. By default in website favicon.ico image is put in the folder or root.
2. this ico type means icon which is displayed in the on browser .
2. this ico type means icon which is displayed in the on browser .
Labels:
Asp.net
Disabling button when performing some operation in ASP.NET
Button1.OnClientClick = ClientScript.GetPostBackEventReference(Button1, "") + "; this.value=’Processing…’;this.disabled = true;";
Labels:
Asp.net
Change default Port of the ASP.NET Development Server
To specify a port for the ASP.NET Development Server - WebSite / WebServices project
1. In Solution Explorer, right click the name of the application.
2. In the Properties pane, click the down-arrow beside Use dynamic ports and select False from the dropdown list. It will enable editing of the Port number property.
3. In the Properties pane, click the text box beside Port number and type in a port number that you want.
4. Click outside of the Properties pane. This saves the property settings.
To specify a port for the ASP.NET Development Server - Web Application project
1. Right click the Project in the Solution Explorer -> select Properties
2. Click Web tab.
3. Check Specific port rather than Auto-assign Port.
2) Restart your system
Yeah in computer science restarting the system normally fix many issues :) . It is better to delete the temporary files by typing %temp% command in run before restarting the system.
3) Change the location of the folder
Change the location of the Folder contains all the files of your website, to some thing else. Load in project in visual studio or visual web developer whatever you have installed in your system and run the project again. and u have done it.
1. In Solution Explorer, right click the name of the application.
2. In the Properties pane, click the down-arrow beside Use dynamic ports and select False from the dropdown list. It will enable editing of the Port number property.
3. In the Properties pane, click the text box beside Port number and type in a port number that you want.
4. Click outside of the Properties pane. This saves the property settings.
To specify a port for the ASP.NET Development Server - Web Application project
1. Right click the Project in the Solution Explorer -> select Properties
2. Click Web tab.
3. Check Specific port rather than Auto-assign Port.
2) Restart your system
Yeah in computer science restarting the system normally fix many issues :) . It is better to delete the temporary files by typing %temp% command in run before restarting the system.
3) Change the location of the folder
Change the location of the Folder contains all the files of your website, to some thing else. Load in project in visual studio or visual web developer whatever you have installed in your system and run the project again. and u have done it.
Labels:
Asp.net
Saturday, June 18, 2011
Photoshop resize image
1. Open photoshop Ctrl + o --> open file
Ctrl + A --> select all
Ctrl + C --> Copy image
then Ctrl + N --> New image
next step Ctrl + V --> Paste here
to do free transform Ctrl + T
then resize from one end
and save it for web.
2.to create duplicate select the area then Ctrl + J
and merge by Ctrl + E --> merge
Ctrl + A --> select all
Ctrl + C --> Copy image
then Ctrl + N --> New image
next step Ctrl + V --> Paste here
to do free transform Ctrl + T
then resize from one end
and save it for web.
2.to create duplicate select the area then Ctrl + J
and merge by Ctrl + E --> merge
Tuesday, June 14, 2011
Jquery how to handle menu selected
1.Make a selected class in Js file Example
2.Provide the Jquery Api on top
3. Use the class on each page like this
< script language="javascript">
$(document).ready(function(){
$(".topnav #menu li #idContactUs").attr("class","selected");
});
</script>
2.Provide the Jquery Api on top
3. Use the class on each page like this
< script language="javascript">
$(document).ready(function(){
$(".topnav #menu li #idContactUs").attr("class","selected");
});
</script>
Labels:
Jquery
Saturday, June 4, 2011
Introduction to Object-Oriented Concept
Object – an abstraction of the behaviour and attributes of the entity being modeled.Behaviour – > methods
Attributes – > properties
Class – template
Objects – instances of the class
The dot(.) operator to access the methods of the object (e.g. car.getName())
ASP.NET controls are objects, ASP.NET pages are objects and data access is achieved using objects.
Objects
Model of an entity
An abstraction of the relevant properties and behaviour of the entity being modeled.
An object has
State (properties or attributes) that describe the object (e.g. name)
Behaviour (or methods) – functions that can be performed by the objects. (e.g. access the objects attributes to retrieve or change the values, getName())
Classes
A template for creating objects or instances of a class.
Defines the attributes or properties of the class and the methods or behaviours for the class.
Instances
Class definitions can be used to create objects that are instances of that particular class.
Variable
A name associated with memory location(s) in your computer.
Where you can store data or information in your program.
Data types
Attribute of a piece of data that tells the computer something about what kind of data is being handled.
Example: Integer, Character, Boolean, String, a particular class.
Declaring Variables
Dim VariableName As DataType
Example: Dim FirstName As String, Dim Age As Integer
Assigning Variables
variable = value
Example: FirstName=”Donald”, Age=10
Double quotes are required for Strings
Explicit conversion:
1
AgeTextBox.Text = Age.ToString()
Statements
Instructions to tell the computer what to do.
Need to result in the correct output.
Sequence – Executed in sequence (one after another)
Decision – Branch statement (choose only one to be executed)
Loop – One or more statements that are repeated until some pre-determined endpoint is reached.
Methods
Use to get a class to perform a task.
Functions – return a value
Sub – does not return a value
Sub
[Accessor] Sub functionName([parameters])
statements
…
…
End Sub
Public Sub DeleteItem(ByVal rowID As Integer)
Items.RemoveAt(rowID)
End Sub
Items – is a collection
rowID – index of the row to be deleted, passed in to the method.
Items.RemoveAt(rowID) – removes the rowIDth row from the items collection.
Function
[Accessor] function functionName([parameters]) As DataType statements
statements
Return value
End Function
Attributes – > properties
Class – template
Objects – instances of the class
The dot(.) operator to access the methods of the object (e.g. car.getName())
ASP.NET controls are objects, ASP.NET pages are objects and data access is achieved using objects.
Objects
Model of an entity
An abstraction of the relevant properties and behaviour of the entity being modeled.
An object has
State (properties or attributes) that describe the object (e.g. name)
Behaviour (or methods) – functions that can be performed by the objects. (e.g. access the objects attributes to retrieve or change the values, getName())
Classes
A template for creating objects or instances of a class.
Defines the attributes or properties of the class and the methods or behaviours for the class.
Instances
Class definitions can be used to create objects that are instances of that particular class.
Variable
A name associated with memory location(s) in your computer.
Where you can store data or information in your program.
Data types
Attribute of a piece of data that tells the computer something about what kind of data is being handled.
Example: Integer, Character, Boolean, String, a particular class.
Declaring Variables
Dim VariableName As DataType
Example: Dim FirstName As String, Dim Age As Integer
Assigning Variables
variable = value
Example: FirstName=”Donald”, Age=10
Double quotes are required for Strings
Explicit conversion:
1
AgeTextBox.Text = Age.ToString()
Statements
Instructions to tell the computer what to do.
Need to result in the correct output.
Sequence – Executed in sequence (one after another)
Decision – Branch statement (choose only one to be executed)
Loop – One or more statements that are repeated until some pre-determined endpoint is reached.
Methods
Use to get a class to perform a task.
Functions – return a value
Sub – does not return a value
Sub
[Accessor] Sub functionName([parameters])
statements
…
…
End Sub
Public Sub DeleteItem(ByVal rowID As Integer)
Items.RemoveAt(rowID)
End Sub
Items – is a collection
rowID – index of the row to be deleted, passed in to the method.
Items.RemoveAt(rowID) – removes the rowIDth row from the items collection.
Function
[Accessor] function functionName([parameters]) As DataType statements
statements
Return value
End Function
Labels:
Asp.net
ASP.NET Controls
Event Driven Programming
The flow of the program is determined by the event.
When an event occurs, the event is said to have been raised or fired.
Event Handler – An event contains the code that runs when an event is raised.
Dynamic web pages – Changes are made via user interaction
Dynamic Web Pages
Events can be processed on the client-side or the server side of the connection.
Client-side processing – code is executed on your computer (the client) and you see the results in the page you are viewing.
Server-side processing – code is executed on the server and the results are delivered to you as part of the html page you are viewing in your browser.
ASP.NET Events
Event handlers for .aspx pages are normally in code-behind(.vb/.cs) files associated with the page.
ASP.NET vs. classic ASP
classic ASP – mix of server-side code and HTML
1
<input type=”text” value=”Time now <%=Time()%>”/>
ASP.NET controls live on the server-side in an ASPX page.
When the page is requested in the browser, the server side controls are processed by the ASP.Net runtime, client side HTML code is apended to the page containing the controls and then sent to the browser.
ASP.NET runtime is the engine that processes ASPX pages on the server.
1
ID – used to uniquely identify a control in a page.
runat=”server” – indicate that the control will be processed on the server.
Postback
When an event is triggered, the page is submitted back to the server for processing, along with information about the event and any pre-existing data on the page(via the ViewState property).
Allows our server code know which items within a drop-down list were selected, or what information a user types into a text box.
Standard or HTML Controls?
Server controls offer more functionality and better design-time support
HTML controls can be used when you don’t need the functionality of the server control.
Ajax (Asynchronous JavaScript And XML) Extensions
Combination of techniques that enable retrieving data from a web server without reloading the whole page.
Enable creation of flicker-free web applications.
WebParts
Allows the user to change the appearance and behaviour of the site.
Allows the user to rearrange content, hide or show parts, and add other content.
ASP.NET State Engine
Stateless HTTP protocol – the web server does not keep track of requests that have been made from a specific browser.
ASP.NET solves this problem by keeping track of the user’s actions via its State Engine.
State Engine remembers the state of the control via a property called ViewState
State Engine stores the current state of many controls at once.
The flow of the program is determined by the event.
When an event occurs, the event is said to have been raised or fired.
Event Handler – An event contains the code that runs when an event is raised.
Dynamic web pages – Changes are made via user interaction
Dynamic Web Pages
Events can be processed on the client-side or the server side of the connection.
Client-side processing – code is executed on your computer (the client) and you see the results in the page you are viewing.
Server-side processing – code is executed on the server and the results are delivered to you as part of the html page you are viewing in your browser.
ASP.NET Events
Event handlers for .aspx pages are normally in code-behind(.vb/.cs) files associated with the page.
ASP.NET vs. classic ASP
classic ASP – mix of server-side code and HTML
1
<input type=”text” value=”Time now <%=Time()%>”/>
ASP.NET controls live on the server-side in an ASPX page.
When the page is requested in the browser, the server side controls are processed by the ASP.Net runtime, client side HTML code is apended to the page containing the controls and then sent to the browser.
ASP.NET runtime is the engine that processes ASPX pages on the server.
1
ID – used to uniquely identify a control in a page.
runat=”server” – indicate that the control will be processed on the server.
Postback
When an event is triggered, the page is submitted back to the server for processing, along with information about the event and any pre-existing data on the page(via the ViewState property).
Allows our server code know which items within a drop-down list were selected, or what information a user types into a text box.
Standard or HTML Controls?
Server controls offer more functionality and better design-time support
HTML controls can be used when you don’t need the functionality of the server control.
Ajax (Asynchronous JavaScript And XML) Extensions
Combination of techniques that enable retrieving data from a web server without reloading the whole page.
Enable creation of flicker-free web applications.
WebParts
Allows the user to change the appearance and behaviour of the site.
Allows the user to rearrange content, hide or show parts, and add other content.
ASP.NET State Engine
Stateless HTTP protocol – the web server does not keep track of requests that have been made from a specific browser.
ASP.NET solves this problem by keeping track of the user’s actions via its State Engine.
State Engine remembers the state of the control via a property called ViewState
State Engine stores the current state of many controls at once.
Labels:
Asp.net
Friday, June 3, 2011
Write data In Excel
Html Code
Code behind page
protected void Page_Load(object sender, EventArgs e)
{
string HospitalData = "Query";
string Servicesdata = "Query2";
hospital = SqlHelper.ExecuteDataset(ConfigurationManager.ConnectionStrings["ConnectionString"].ToString(), CommandType.Text, HospitalData);
Services = SqlHelper.ExecuteDataset(ConfigurationManager.ConnectionStrings["ConnectionString"].ToString(), CommandType.Text, Servicesdata);
DataTable HDT = hospital.Tables[0];
DataTable SDT = Services.Tables[0];
DataTable PrintRecord = CreateDataTable();
PrintRecord.Clear();
foreach (DataRow dr in HDT.Rows)
{
DataRow objDR = PrintRecord.NewRow();
objDR["Hospital"] = dr["Hospital"];
objDR["Address"] = dr["Address"];
objDR["City"] = dr["City"];
objDR["State"] = dr["State"];
objDR["Phone"] = dr["Phone"];
objDR["Fax"] = dr["Fax"];
objDR["Email"] = dr["Email"];
objDR["Website"] = dr["Website"];
string ser = string.Empty;
foreach (DataRow dr1 in SDT.Rows)
{
if(dr1["PropertyID"].ToString().Trim() == dr["PropertyID"].ToString().Trim())
{
ser = ser + dr1["Service"].ToString() + "
";
//DataRow objDR1 = PrintRecord.NewRow();
//objDR1["Services"] = dr1["Service"].ToString();
//PrintRecord.Rows.Add(objDR1);
}
}
objDR["Services"] = ser.ToString();
PrintRecord.Rows.Add(objDR);
//DataGrid DataGrid1 = new DataGrid();
DataGrid1.DataSource = PrintRecord;
DataGrid1.DataBind();
string filename = dr["Hospital"].ToString().Trim().Replace(" ", "_").Replace(".", "").Replace("\'", "").Replace("(", " ").Replace(")", "").Replace("/", "").Replace("\\", "").Replace("'", "");
this.DataGrid1.Page.EnableViewState = false;
StringWriter tw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(tw);
this.DataGrid1.RenderControl(hw);
string HtmlInfo = tw.ToString().Trim();
string DocFileName = filename + ".xls";
string FilePathName = Request.PhysicalPath;
FilePathName = FilePathName.Substring(0, FilePathName.LastIndexOf("\\"));
FilePathName = FilePathName + "\\Excal" + "\\" + DocFileName;
File.Delete(FilePathName);
FileStream Fs = new FileStream(FilePathName, FileMode.Create);
BinaryWriter BWriter = new BinaryWriter(Fs, Encoding.GetEncoding("UTF-8"));
BWriter.Write(HtmlInfo);
BWriter.Close();
Fs.Close();
//Write Excal File and save.
PrintRecord.Clear();
}
}
// structure of datatable
public static DataTable CreateDataTable()
{
DataTable dt = new DataTable();
DataColumn dc;
dc = new DataColumn("Hospital");
dt.Columns.Add(dc);
dc = new DataColumn("Services");
dt.Columns.Add(dc);
dc = new DataColumn("Address");
dt.Columns.Add(dc);
dc = new DataColumn("City");
dt.Columns.Add(dc);
dc = new DataColumn("State");
dt.Columns.Add(dc);
dc = new DataColumn("Phone");
dt.Columns.Add(dc);
dc = new DataColumn("Fax");
dt.Columns.Add(dc);
dc = new DataColumn("Email");
dt.Columns.Add(dc);
dc = new DataColumn("Website");
dt.Columns.Add(dc);
return dt;
}
Code behind page
protected void Page_Load(object sender, EventArgs e)
{
string HospitalData = "Query";
string Servicesdata = "Query2";
hospital = SqlHelper.ExecuteDataset(ConfigurationManager.ConnectionStrings["ConnectionString"].ToString(), CommandType.Text, HospitalData);
Services = SqlHelper.ExecuteDataset(ConfigurationManager.ConnectionStrings["ConnectionString"].ToString(), CommandType.Text, Servicesdata);
DataTable HDT = hospital.Tables[0];
DataTable SDT = Services.Tables[0];
DataTable PrintRecord = CreateDataTable();
PrintRecord.Clear();
foreach (DataRow dr in HDT.Rows)
{
DataRow objDR = PrintRecord.NewRow();
objDR["Hospital"] = dr["Hospital"];
objDR["Address"] = dr["Address"];
objDR["City"] = dr["City"];
objDR["State"] = dr["State"];
objDR["Phone"] = dr["Phone"];
objDR["Fax"] = dr["Fax"];
objDR["Email"] = dr["Email"];
objDR["Website"] = dr["Website"];
string ser = string.Empty;
foreach (DataRow dr1 in SDT.Rows)
{
if(dr1["PropertyID"].ToString().Trim() == dr["PropertyID"].ToString().Trim())
{
ser = ser + dr1["Service"].ToString() + "
";
//DataRow objDR1 = PrintRecord.NewRow();
//objDR1["Services"] = dr1["Service"].ToString();
//PrintRecord.Rows.Add(objDR1);
}
}
objDR["Services"] = ser.ToString();
PrintRecord.Rows.Add(objDR);
//DataGrid DataGrid1 = new DataGrid();
DataGrid1.DataSource = PrintRecord;
DataGrid1.DataBind();
string filename = dr["Hospital"].ToString().Trim().Replace(" ", "_").Replace(".", "").Replace("\'", "").Replace("(", " ").Replace(")", "").Replace("/", "").Replace("\\", "").Replace("'", "");
this.DataGrid1.Page.EnableViewState = false;
StringWriter tw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(tw);
this.DataGrid1.RenderControl(hw);
string HtmlInfo = tw.ToString().Trim();
string DocFileName = filename + ".xls";
string FilePathName = Request.PhysicalPath;
FilePathName = FilePathName.Substring(0, FilePathName.LastIndexOf("\\"));
FilePathName = FilePathName + "\\Excal" + "\\" + DocFileName;
File.Delete(FilePathName);
FileStream Fs = new FileStream(FilePathName, FileMode.Create);
BinaryWriter BWriter = new BinaryWriter(Fs, Encoding.GetEncoding("UTF-8"));
BWriter.Write(HtmlInfo);
BWriter.Close();
Fs.Close();
//Write Excal File and save.
PrintRecord.Clear();
}
}
// structure of datatable
public static DataTable CreateDataTable()
{
DataTable dt = new DataTable();
DataColumn dc;
dc = new DataColumn("Hospital");
dt.Columns.Add(dc);
dc = new DataColumn("Services");
dt.Columns.Add(dc);
dc = new DataColumn("Address");
dt.Columns.Add(dc);
dc = new DataColumn("City");
dt.Columns.Add(dc);
dc = new DataColumn("State");
dt.Columns.Add(dc);
dc = new DataColumn("Phone");
dt.Columns.Add(dc);
dc = new DataColumn("Fax");
dt.Columns.Add(dc);
dc = new DataColumn("Email");
dt.Columns.Add(dc);
dc = new DataColumn("Website");
dt.Columns.Add(dc);
return dt;
}
Labels:
Asp.net
Thursday, June 2, 2011
Subscribe to:
Posts (Atom)