user2210516
user2210516

Reputation: 683

Hyperlink with parameters asp.net

Lets say i have a startpage home.aspx with 3 links to different carbrands like

BMW VW Volvo

I set a querystring to add id for the brand like brands.aspx?id=1 for BMW 2 for VW and 3 for Volvo.

This way i can use the same code for all 3 brands but the Content will Change depending on id. In the brands page i Show the different models from the cars. Like BMW m3, BMW 325 and so on...

Now to my Problem, i want to be able to click on for example BMW m3 and get even deeper and go to all different styles from that Special model. For example BMW m3 Turbo black, BMW m3 red...

How can get the value of the id on the page i visit and send it as a Parameter on the new links? I dont want to write the code in code behind.

It should be like this models.aspx?id=@id&model=1020

Hope you understand what im looking for

Upvotes: 1

Views: 15022

Answers (3)

Majid
Majid

Reputation: 14253

To get id use :

var id=Request.QueryString["id"];

then

myLink.HRef="models.aspx?id="+id+"&model=1020";

remember that your link should have runat="server" in its definition.

Upvotes: 2

Majid
Majid

Reputation: 14253

If you don't want to use code behind,so use this in your aspx file:

<a href="models.aspx?id=<%=Request.QueryString["id"] %>&amp;model=1020">link</a>

Upvotes: 3

Arun Bertil
Arun Bertil

Reputation: 4638

Response.Redirect("Default.aspx?id="+id.Text+"&model="+model.Text+"&modelname="+modelname.Text");

Upvotes: 0

Related Questions