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. Color parameter in query string ?

Color parameter in query string ?

Scheduled Pinned Locked Moved ASP.NET
helpquestiondatabase
3 Posts 3 Posters 6 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.
  • P Offline
    P Offline
    paper67
    wrote on last edited by
    #1

    I'm calling and aspx page with a color param. I need this color to be passed on the querystring, so I call the aspx as: somepage.aspx?color=#FFFFFF&... The color parameter in the querystring is set by ColorTranslator.ToHtml(Color) I think here the problem is the # symbol. Is there a problem passing # as a parameter? How can i get back my Color object from this querystring ? I tried : if (!string.IsNullOrEmpty(Context.Request.QueryString["color"])) Color = ColorTranslator.FromHtml(Context.Request.QueryString["color"]); but for some reason the above if statement evaluates to false. How can I fix this ? TIA

    S A 2 Replies Last reply
    0
    • P paper67

      I'm calling and aspx page with a color param. I need this color to be passed on the querystring, so I call the aspx as: somepage.aspx?color=#FFFFFF&... The color parameter in the querystring is set by ColorTranslator.ToHtml(Color) I think here the problem is the # symbol. Is there a problem passing # as a parameter? How can i get back my Color object from this querystring ? I tried : if (!string.IsNullOrEmpty(Context.Request.QueryString["color"])) Color = ColorTranslator.FromHtml(Context.Request.QueryString["color"]); but for some reason the above if statement evaluates to false. How can I fix this ? TIA

      S Offline
      S Offline
      Steve Wellens
      wrote on last edited by
      #2

      This seems to work:

      protected void Page\_Load(object sender, EventArgs e)
      {
          String Color;
          if (Request.QueryString\["color"\] != null)
          {
              Color = Request.QueryString\["color"\];
          }
      } 
      
      protected void Button1\_Click1(object sender, EventArgs e)
      {
          String URL = "Default.aspx?color=" + Server.UrlEncode("#FFFFFF");
          Response.Redirect(URL);
      

      }

      Steve Wellens

      1 Reply Last reply
      0
      • P paper67

        I'm calling and aspx page with a color param. I need this color to be passed on the querystring, so I call the aspx as: somepage.aspx?color=#FFFFFF&... The color parameter in the querystring is set by ColorTranslator.ToHtml(Color) I think here the problem is the # symbol. Is there a problem passing # as a parameter? How can i get back my Color object from this querystring ? I tried : if (!string.IsNullOrEmpty(Context.Request.QueryString["color"])) Color = ColorTranslator.FromHtml(Context.Request.QueryString["color"]); but for some reason the above if statement evaluates to false. How can I fix this ? TIA

        A Offline
        A Offline
        Abhishek Sur
        wrote on last edited by
        #3

        You mean

        paper67 wrote:

        if (!string.IsNullOrEmpty(Context.Request.QueryString["color"]))

        Evaluates to false ? Did you put the QueryString correctly. Use HttpUtility.UrlEncode before sending the color code. And after fetching use HttpUtility.UrlDecode to get the color code back properly.

        Abhishek Sur **Don't forget to click "Good Answer" if you like this Solution.


        My Latest Articles-->****
        InfoBox Visual Studio 2010 Extension
        Windows7 API Code Pack
        Simplify Code Using NDepend**

        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