Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Problem with ListView and Request.QueryString [modified]

Problem with ListView and Request.QueryString [modified]

Scheduled Pinned Locked Moved ASP.NET
helpsysadmin
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    foahchon
    wrote on last edited by
    #1

    Hi, I'm trying to insert some text from the page's QueryString into a LayoutTemplate inside a ListView, but something so seemingly simple is proving to be very difficult (for me, at least). Here's the code I have for my LayoutTemplate:

            <LayoutTemplate>
                <h1><%# Request.QueryString\["itemtype"\] %> Items</h1>
                <asp:PlaceHolder ID="itemPlaceholder" runat="server"></asp:PlaceHolder>
            </LayoutTemplate>
    

    The problem is that only "Items" shows up. I have also tried the <%= tag, but then it tells me the control cannot be modified because it contains code blocks. I'm running out of ideas, so any help would be greatly appreciated. Thanks.

    modified on Monday, February 11, 2008 8:46 PM

    D 1 Reply Last reply
    0
    • F foahchon

      Hi, I'm trying to insert some text from the page's QueryString into a LayoutTemplate inside a ListView, but something so seemingly simple is proving to be very difficult (for me, at least). Here's the code I have for my LayoutTemplate:

              <LayoutTemplate>
                  <h1><%# Request.QueryString\["itemtype"\] %> Items</h1>
                  <asp:PlaceHolder ID="itemPlaceholder" runat="server"></asp:PlaceHolder>
              </LayoutTemplate>
      

      The problem is that only "Items" shows up. I have also tried the <%= tag, but then it tells me the control cannot be modified because it contains code blocks. I'm running out of ideas, so any help would be greatly appreciated. Thanks.

      modified on Monday, February 11, 2008 8:46 PM

      D Offline
      D Offline
      dojohansen
      wrote on last edited by
      #2

      I'm not a fan of this asp-style coding so I can't really help you unless you're willing to use the asp.net-style code-behind feature... but if you are, run the heading tag on the server and set it's text programmatically: .aspx:

      Code-behind (.aspx.cs or .vb or ... - I choose C#):

      void Page_Load(object sender, EventArgs e)
      {
      heading.InnerHtml = Request.Params["itemtype"] + " Items";
      }

      Notice that this solution has the additional benefit of protecting against script injections because the parameter will be interpreted as HTML code, not just literal text. Hence, a user putting

      p.aspx?itemtype=close()

      in the adress bar (or more problematically, manages to save an itemtype named so the database, causing other users to be directed to such a url) will render the > and < characters as > and < hence just displaying the text rather than execute the script!

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups