I am trying to allow a user to specify a background color for my asp.net website. So I want to pass the page color into my url like:
UserDetails.aspx?Color=#FFFFFF
However as soon as I include the # character I can’t seem to be able to get the correct value for the parameter Color using:
color = System.Drawing.ColorTranslator.FromHtml(Request.Params["Color"]);
Please help
The pound character (#) is used in URLs to indicate where a fragment identifier (bookmarks/anchors in HTML) begins. You’ll probably want to URL encode it as %23.
Or, as Andrew noted in a comment, you could have the user pass the parameter without the pound sign and add it in later.