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