PDA

View Full Version : ASP.NET 2.0 Question: Passing Data to Another Page


gstelmack
10-10-2007, 08:14 PM
What I'd like to do:

Have a page with a list of, say, 32 teams. You click a team, and another page opens with data on that team.

My understanding is I can do a link that looks something like:

hxxp://www.myleaguesite.net/TeamInfoPage.aspx?teamid=7

Correct? But how do I pull that teamid out on TeamInfoPage.aspx so I can look up and display that team?

Yes, I'm a complete noob at web stuff, please bear with me. I've got lots of stuff figured out, but my handful of attempts at this one piece have ended in miserable failure. I'm also willing to go with other options if they'll work better for ASP.NET 2.0.

sabotai
10-10-2007, 08:29 PM
It's been a very long time since I messed around with ASP, but I think I used VBScript to get the value of variables from the HTTP. I don't think there's anything in ASP itself that will pull the value.

But this was about 6-7 years ago, so I may be very wrong on that.

Neon_Chaos
10-10-2007, 08:52 PM
Use Context.Item

There are several tutorials on the web. You can pass the contents into another webpage after doing a server transfer. The containing data will only exist for that one state, and will expire after that state passes.

Neon_Chaos
10-10-2007, 08:53 PM
Or, if you're working with a VB.Net backbone behind the ASP.Net, you can just create a masterpage, and have everything work inside, so you can encapsulate data and just keep passing variables back and forth via the VB.Net framework.

lordscarlet
10-10-2007, 09:17 PM
If you're still using nhibernate there's a way to quickly do it (you just query the db again with the id specified), I can look it up tomorrow, as I'm about to head to bed and don't remember it off the top of my head.

lordscarlet
10-10-2007, 09:21 PM
dola:

maybe: Customer customer = (Customer)
session.Load(typeof(Customer), "ALFKI");

cuervo72
10-10-2007, 10:06 PM
Request.QueryString("teamid") ? Or does that only work in regular asp?

(also, Request("teamid") works generically for both Request.QueryString and Request.Form - I think)

cuervo72
10-10-2007, 10:09 PM
Dola - you could always use php.... ;)

(I could hook you up with some things)

Fidatelo
10-10-2007, 11:09 PM
Request.QueryString("teamid") ? Or does that only work in regular asp?

(also, Request("teamid") works generically for both Request.QueryString and Request.Form - I think)

Request.QueryString is the easiest way to do it if the data is being passed in via the URL as gstelmack suggests.

lordscarlet
10-11-2007, 05:55 AM
ohhhhhh.. you just want to get the actual id in the querystring??

Request.QueryString["TeamId"] or Request.Parameter["TeamId"] should work fine.

You'll also want to cast it..

Convert.ToInt32(Request.QueryString["TeamId"]);

gstelmack
10-11-2007, 08:24 AM
Thanks, I think Request.QueryString is exactly what I'm looking for.

I'm not using PHP because I know C# well enough that I'm actually able to get some stuff done (and I love the language). Plus I'm having fun learning ASP.NET 2.0. I've been able to do some pretty cool stuff using C# (I'm pretty proud of the auto-league-calendar generator I've got for WOOF...)

Fidatelo
10-11-2007, 09:02 AM
C# is a pretty cool language, I moved to it from VB.NET about 6 months ago and I've never looked back.

That said, I'm getting really tempted to dive into the Ruby on Rails stuff.

lordscarlet
10-11-2007, 10:10 AM
C# is a pretty cool language, I moved to it from VB.NET about 6 months ago and I've never looked back.

That said, I'm getting really tempted to dive into the Ruby on Rails stuff.

I am a C# (ASP.NET) developer by profession. I spent about 6 months doing Rails on the side and loved it. Ultimately I decided to put it to bed because it wasn't advancing my knowledge for my career like developing in C# on the side would be. But rails is fantastic.

Fidatelo
10-11-2007, 10:15 AM
I'm a .NET dev by profession too, and it is those same doubts about "wasting my time" that have kept me away from Rails. That said, with MVP's like Scott Bellware making the switch, it really has me thinking.

Locally a group of guys has started a Rails User Group. Their second meeting is next month so I think I will do a little studying beforehand and then attend. Part of me thinks it might be tempting to switch gears career-wise if the right alternative popped up...

lordscarlet
10-11-2007, 10:35 AM
I'm a .NET dev by profession too, and it is those same doubts about "wasting my time" that have kept me away from Rails. That said, with MVP's like Scott Bellware making the switch, it really has me thinking.

Locally a group of guys has started a Rails User Group. Their second meeting is next month so I think I will do a little studying beforehand and then attend. Part of me thinks it might be tempting to switch gears career-wise if the right alternative popped up...

If you'll consider switching gears completely, it's definitely worth trying out. I am too happy with my job to switch over to Rails, but if I wasn't I would love to find a job doing Rails.

MikeVic
10-11-2007, 10:37 AM
I'm a .NET dev by profession too, and it is those same doubts about "wasting my time" that have kept me away from Rails. That said, with MVP's like Scott Bellware making the switch, it really has me thinking.

Locally a group of guys has started a Rails User Group. Their second meeting is next month so I think I will do a little studying beforehand and then attend. Part of me thinks it might be tempting to switch gears career-wise if the right alternative popped up...

I go to the .NET User Group! They mentioned this about Ruby on Rails. I don't do web dev, so I've never used it.

http://www.railsmanitoba.com/

Fidatelo
10-11-2007, 10:53 AM
I go to the .NET User Group! They mentioned this about Ruby on Rails. I don't do web dev, so I've never used it.

http://www.railsmanitoba.com/

Heh, cool, I bet we were in the same room on tuesday listening to John Bristowe :)

MikeVic
10-11-2007, 10:56 AM
Heh, cool, I bet we were in the same room on tuesday listening to John Bristowe :)

That's freaky. There weren't many people there...

ThunderingHERD
10-11-2007, 11:01 AM
Are there really there really a lot of enterprise apps using Rails? I don't really know anything about it, but I had the impression that it was more of a "Web 2.0" fad.

Fidatelo
10-11-2007, 11:02 AM
That's freaky. There weren't many people there...

You didn't happen to go out for drinks at Bailey's after did you?...

gstelmack
10-11-2007, 11:18 AM
Are there really there really a lot of enterprise apps using Rails? I don't really know anything about it, but I had the impression that it was more of a "Web 2.0" fad.

My experiences with Rails are colored by the host that WOOF was on...

MikeVic
10-11-2007, 11:37 AM
You didn't happen to go out for drinks at Bailey's after did you?...

Haha no I didn't. I've been fighting a cold, and I was still feeling weak. Didn't wanna drink. :)

lordscarlet
10-11-2007, 12:37 PM
Are there really there really a lot of enterprise apps using Rails? I don't really know anything about it, but I had the impression that it was more of a "Web 2.0" fad.

There are definitely some mid-level ones, and probably some sites you use, but I don't know about enterprise.

My experiences with Rails are colored by the host that WOOF was on...

Yeah.. dreamhost has a lot of haters for different reasons, probably mostly justified.

Fidatelo
10-11-2007, 01:52 PM
Haha no I didn't. I've been fighting a cold, and I was still feeling weak. Didn't wanna drink. :)

Heh, cool. You know, I'm gonna end up profiling the whole crowd at the next one now :P

MikeVic
10-11-2007, 02:01 PM
Heh, cool. You know, I'm gonna end up profiling the whole crowd at the next one now :P

Haha. I'll be hiding.

Fidatelo
10-11-2007, 02:27 PM
Well that will be easy then, I'll just look for the guy crouched behind a chair...

MikeVic
10-11-2007, 02:28 PM
Well that will be easy then, I'll just look for the guy crouched behind a chair...

Good point.