This blog is about the dotnet.all types of codes,news about dotnet including asp.net,vb.net,c# and know about new dotnet technology.programing in asp.net,vb.net,c#, ajax, AJAX tech support for .net and discuss the new technology in dotnet.ncluding asp.net,vb.net,c# and know about new dotnet technology.programing in asp.net,vb.net,c#, ajax, AJAX tech support for .net and discuss the new technology in dotnet.asp.net programming,dot net programming,dotnet programs,dotnet source code,source code.

Free Hosting

Free Hosting

Sunday, January 4, 2009

Passing Parameters in ASP.NET

Version: ASP.NET 1.0
Compatibility: ASP.NET 1.0
Category: ASP.NET


I'm frequently asked how to pass parameters from one page to another page in ASP.NET.

This is a beginner's question and every ASP.NET developer should master this concept. So if you don't already know the answer, then definitely read on...

I get asked this alot as our charting tool is implemented via two web pages. One web page has a server chart control that renders as HTML (either an IMG or CLSID object tag.) The second page has a server control that streams the bits constituting the object created via HTML from the first page. This process is ideal for web-farm environments as it's purely scaleable.

To help visualize the problem. Take a look at www.gigasoft.com/financial.aspx

On the left hand side of chart the user can select a stock symbol to load the corresponding stock data.

To implement such a site...

Declarations:
'none

CODE:
'Within the Page_Load for the form1 (Financial.aspx.cs)

// Add a parameter to pass volume checkbox data
string s = "";
if (VolumeCheckbox.Checked == true)
s = s + "Volume=1";
else
s = s + "Volume=0";

// Add a parameter to pass symbol combobox data
s = s + "&Symbol=" + SymbolComboBox.Value.ToString();

PegoWeb1.ImageUrl = "Financial2.aspx?" + s;


Within the Page_Load of the form2.
string sVolume;
string sSymbol;
sVolume = this.Request.QueryString.Get("Volume");
sSymbol = this.Request.QueryString.Get("Symbol");


Note the "?" at end of ImageUrl = "Financial2.aspx?".
Note you can string together multiple parameters separating with "&" symbol.

0 comments:

dotnet(.Net) Project Source code Downloads and Tutorials

Email Subscrption



Enter your email address:

Delivered by FeedBurner

Feedburner Count

Blog Archive

Unique Visitor

Design by araba-cı | MoneyGenerator Blogger Template by GosuBlogger