Forum Moderators: open

Message Too Old, No Replies

New asp.net user question

asp.net get variables

         

belfasttim

10:44 pm on Nov 5, 2009 (gmt 0)

10+ Year Member



Hi all-- I'm new to asp.net, but pretty experienced with web development in general, PHP especially.

I'm getting pretty frustrated with a particular example I'm trying to do-- I want to pass a URL variable (GET) called "region"-- so right now the URL I'm requesting looks like

[mysite.com...]

on the mypage.aspx page, I have the following code--


<script runat="server">
Sub Page_load (ByVal Sender as Object, ByVal E As System.EventArgs)
RegionTag.Text = Request.QueryString("region")
End Sub
</script>

<asp:Label id="RegionTag" runat="server" />


(other code stuff).

Now, the page renders just fine, but I can't for the life of me get that URL var to show up, either using the Text method of the RegionTag or even a Response.Write. Any advice?

Thanks

Ocean10000

5:44 am on Nov 6, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I am assuming the Page_Load is not being called. The only thing I can think of its it not being linked to the Load Event. Try the following snip-it. Only difference is I added " Handles Me.Load" which links it to the load event.

<script runat="server">
Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
RegionTag.Text = Request.QueryString("region")
End Sub
</script>

belfasttim

8:08 am on Nov 6, 2009 (gmt 0)

10+ Year Member



Thanks for the help Ocean.. .still not working. It shouldn't matter that I'm doing the "CTRL-F5" method of testing the page rather than putting it on a real webserver, should it?

marcel

8:31 am on Nov 6, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It shouldn't matter that I'm doing the "CTRL-F5" method of testing the page rather than putting it on a real web server, should it?

No, it shouldn't make a difference.

Have you tried setting a breakpoint at the RegionTag.Text = Request.QueryString("region") line and running it in debug mode? (F5 without CTRL)

Does the debugger pause at that point? if not the Sub is not being called, as Ocean suspected.

belfasttim

4:40 pm on Nov 6, 2009 (gmt 0)

10+ Year Member



Thanks Marcel, I tried that and no, there was no hitch in rendering the page. So why would the sub not be called?

belfasttim

7:46 pm on Nov 6, 2009 (gmt 0)

10+ Year Member



Update: I'm not sure if something is just going wrong with my system, but I tried it again, with the debug, and it did stop at the point Marcel specified.

I don't know what I do next however!

Thanks