User Id :    Password :      New Member   Forgot Password  
 
How to pass the values from aspx page to asp page in a same project
Description In this article I will show you how asp.net and asp pages can exchange information from each other in the same project   No. of Views     1877
  Rating     3
Author Jalpesh Vadgama   Posted On     15 Jun 2010
Tags    

Sample Code   Download Code

How to pass the values from aspx page to asp page in a same project.
If you have asp and asp.net pages in your project and you want to send the values from asp.net page to asp page then there are two ways;

1) Using Database
2) Using Cookies

Sometimes using database is not useful for us then we can use cookies for that task. You can use session for that because sessions can’t carry the values from one asp.net page to asp page.
Now see how we can use cookies.
A cookie is stored on the client's machine by their web browser software. To set a cookie, we include information in an HttpResponse that instructs the browser to save a cookie on the client's system. Here's the basic code for writing a Cookie in ASP.NET.

Using System.Web;
Response.Cookies["tutorials”].Value = "DotNetLogix”;

And to read the cookie back:
Response.Write(Request.Cookies["tutorials"].Value);

Note that for security reasons you can only read a cookie that was set within the same domain name.

Sometimes you may need a collection of stored items, such as user address details. In this case you could read in a cookie collection like this:

HttpCookieCollection cookies = Request.Cookies;

for(int n=0;n<=cookies.Count-1;n++)
{
    HttpCookie cookie = cookies[n];
    Response.Write("
Name: " + cookie.Name + "
"); Response.Write("Expiry: " + cookie.Expires + "
"); Response.Write("Address1: " + cookie.Address1+ "
"); Response.Write("Address2: " + cookie.Address2+ "
"); Response.Write("City: " + cookie.City+ "
"); Response.Write("Zip: " + cookie.Zip+ "
"); }


Finally, you can see details of cookies during development, by turning on tracing in ASP.NET. Within the @Page directive at the start of the page simply adds Trace="true”:

<%@ Page trace="true" language="c#" Codebehind="page.aspx.cs" Inherits="MyPage" %>

About Author

About Author I am jalpesh vadgama an Microsoft MVP for Visual C# and BrainBench Certified ASP.NET Developer having more then 5 years of experience in .NET Technology.Please feel free to contact me for any queries via posting comments on my blog I will try to reply as early as possible. Please also visit my blog at http://jalpesh.blogspot.com/ Jalpesh Vadgama
No Photo
 
Country India
Company N/A
Home Page http://jalpesh.blogspot.com/

Rate this article

Rating options from poor, fair, good, very good to excelent.  
 

Comments

   
Write your comment here.
Comment
Verification Code