none
Requesting a value from url into the href on a master page

    Question

  • In the browser a user clicked on a link to a page that adds a variable and value to the end of the url.  Such as: default.aspx?chapter=13

    The page where the user went to has a master page attached to it.  As a part of that master page are a few links at the bottom of the page.  I would like to have these links capture and append that value of 13 to the href.

    This is the link in my master page.  I would like the 13 to be added to the end of ...chapter=

         <a class="auto-style5" href="statement.aspx?type=about+us&amp;chapter=">
         <span class="auto-style22">About Us</span></a>

    Friday, November 26, 2010 4:39 AM

Answers

  • What language is the page?  VB or C#?  If C#, your QueryString syntax is wrong.  [], not ().  That will give the error you are getting.

    • Marked as answer by rmuscarello Saturday, November 27, 2010 2:56 AM
    Friday, November 26, 2010 4:50 PM

All replies

  • Links are links, static values, and they do not "capture" anything. If you want to alter the value of the link, read the incoming QueryString value and append it to the end of the value contained in the control (textbox, label, whatever) holding the link. This is a programmatic action, not a function of a hyperlink, and there is no automatic way to do it.

    cheers,
    scott


    Please remember to "Mark as Answer" the responses that resolved your issue. It is common courtesy to recognize those who have helped you, and it also makes it easier for visitors to find the resolution later.
    Friday, November 26, 2010 2:27 PM
  • I have been trying to use Request.QueryString but I can't seem to get it to work.

    <a class="auto-style5" href="statement.aspx?type=about+us&amp;chapter=<%=Request.QueryString("chapter")%>">
         <span class="auto-style22">About Us</span></a>

    Then I get this 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: CS1955: Non-invocable member 'System.Web.HttpRequest.QueryString' cannot be used like a method.

    Source Error:

    Line 219:					</span></td>
    Line 220:					<td style="width: 114px" class="auto-style18">
    Line 221:					<a class="auto-style5" href="statement.aspx?type=about+us&amp;chapter=<%=Request.QueryString("chapter")%>">
    Line 222:					<span class="auto-style22">About Us</span></a></td>
    Line 223:					<td style="width: 114px" class="auto-style21">


    Roger Muscarello
    Friday, November 26, 2010 2:50 PM
  • What language is the page?  VB or C#?  If C#, your QueryString syntax is wrong.  [], not ().  That will give the error you are getting.

    • Marked as answer by rmuscarello Saturday, November 27, 2010 2:56 AM
    Friday, November 26, 2010 4:50 PM
  • How would I do this in an asp:MenuItem?  I getting an error trying to use it here.

    Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

    Parser Error Message: Literal content ('<asp:MenuItem NavigateUrl="trailrides.aspx?chapter=') is not allowed within a 'System.Web.UI.WebControls.MenuItemCollection'.

    Source Error:

    Line 235:				<Items>
    Line 236:					<asp:MenuItem Selectable="False" Text="Root Menu 1" Value="Root Menu 1">
    Line 237:						<asp:MenuItem NavigateUrl="trailrides.aspx?chapter=<%=Request.QueryString["chapter"]%>" Text="Trail Rides" Value="New Item">
    Line 238:						</asp:MenuItem>
    Line 239:					</asp:MenuItem>

    Server Error in '/' Application.

    Parser Error

     


    Roger Muscarello
    Saturday, November 27, 2010 10:39 PM