Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Noob question

Status
Not open for further replies.

MalCarne

Technical User
Apr 1, 2005
70
US
I'm just trying this .net thing out. I've been programming in asp for a few years and I'm having a hard time leaving old ways behind.
In this:
Code:
<script runat="server">
    public void Page_Load(Object Source, EventArgs E)
    {
        String company_id = Page.Request.QueryString["company_id"];
        referer.Text = company_id;
    }
</script>

<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml"[/URL] >
<head runat="server">
    <title>Untitled Page</title>
    <link rel =stylesheet href=css/<%=company_id%>.css />
</head>

Trying to use the variable "company_id" as <%=company_id%> is not working outside of the <script> block.
How does one refer to a variable outside of the script block?
 
Not sure how that page works as I haven't downloaded the sample app, but the easiest method would be to use a Literal control and set it's Text. e.g.



____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.
 
Thanks, but that is a bit more specific than I'm trying for here.

In the bigger picture, I'm trying to understand how to use variables outside of the script block. It's common practice in asp, but it's giving me fits here.
Is this something that can't be done anymore, or am I going about it in completely the wrong way?
 
Who is that reply for (if it's for me, I'm confused as to why it's a bit more specific)?

The link I sent does exactly what you've already done for setting the Text property of another control, but instead of using a link, you use a literal control so you can access it's Text property.



____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Sorry, it was originally for jbenson and you'd posted while I was posting. But, the same applies.... bear with me, I'm a complete noob with .net and C# in particular. The links that the two of you provided are a bit over my tiny reptilian head at this point.

In asp, what I'm trying to accomplish can be done with a variable and string concantenation. From the examples that you've shown, I'm guessing that this can no longer be done? If that's the case, why? I'm just feeding some code to be interpreted into html.

Now, back to the broader scope of my original question; within the page_load function I can decalare a varible "x" and assign it to request.querystring["whatever"]. It now makes sense that "x" has no reference outside of that function. However, I've tried to declare it as a public string, just a string, and a few other ways. What I'm running across is that page.request.querystring is only valid within that function... and it's kind of baffling to me.
Can someone explain?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top