A Simple problem for a complete beginner...

Discussion in 'C#' started by pingo, Jun 17, 2007.

  1. #1
    Hi guys,

    I've been thrown in the shallow end of this so forgive me for my ignorance with this post. I'm a PHP developer but the contract I am currently working on has some websites that were built using ASP.NET. The problem is simple: I need to check for the id of a page and display a different meta description based on what page it is on.

    But I'm not sure what the process is with ASP... do I need to compile after making any changes? For example the following code:

    <%
    Request.QueryString["Category"];
    %>

    Generates are compilation error:
    Compilation Error
    Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

    Compiler Error Message: CS0201: Only assignment, call, increment, decrement, and new object expressions can be used as a statement

    Source Error:

    Line 10: <!-- InstanceBeginEditable name="SEO Meta" -->
    Line 11: <%
    Line 12: Request.QueryString["Category"];
    Line 13: %>
    Line 14: <meta name="Description" content="" />


    Source File: e:\inetpub\esvc001096\Catalogue.aspx Line: 12


    I know, I know... I should spend some time learning it, but they've sprung it on me this morning (the asp programmer is away), it needs to be done yesterday.... and I never thought I would ever be required to program in ASP!

    Thanks for your help.
     
    pingo, Jun 17, 2007 IP
  2. tarponkeith

    tarponkeith Well-Known Member

    Messages:
    4,758
    Likes Received:
    279
    Best Answers:
    0
    Trophy Points:
    180
    #2
    Is it supposed to be ASP.NET?
    If it's classic ASP, then you should assign the request to a variable, and use parenthesis, not brackets...

    <%
    dim strInCategory
    strInCategory = request.querystring("Category")
    %>

    If you need .NET help, please disregard this post, and good luck...
     
    tarponkeith, Jun 17, 2007 IP
  3. newbish

    newbish Peon

    Messages:
    27
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    To display that information you can do it a couple ways:

    1. <%=Request.QueryString["Category"]%>
      Code (markup):
    2. <%Response.Write(Request.QueryString["Category"]);%>
      Code (markup):

    Form the information in your post I guess the information is probably in a database or something in which case you will most likely do this in a code behind to a label.

    something.aspx
    
    <meta name="Description" content="<asp:label id="Label1" runat="server"/>" />
    
    Code (markup):
    something.aspx.cs
    Label1.Text = somevariable;
    Code (markup):
     
    newbish, Jun 19, 2007 IP