Answered by:
Simple Data Issue, I think.

Question
-
User-2034757353 posted
So, I'm trying to make a practice page. I'm trying to teach myself this technology. Anyway, as for my issue, I'm
having an issue sending the value from the 'other' textbox (TextBox1) to the OtherColor.aspx. It has a problem
with me using the script in the font forecolor and text to
<%var color = Server.UrlDecode(Request.QueryString["Data"]);%>. Am I missing something? Is there a way to
make it a string variable to pass into the text setting command?
The idea is that I want to have someone enter a color in the textbox and when they hit submit have their color
show up as text and as the color of that text. I'm not checking the vaildity of the entered color yet.
HOME PAGE ASPX: <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication1.WebForm1" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>Pick Your Color!</title> </head> <body> <form id="form1" runat="server"> <div> <h1>Pick Your Color!</h1> <asp:RadioButtonList ID="RadioButtonList1" runat="server"> <asp:ListItem Selected="True">RED</asp:ListItem> <asp:ListItem>BLUE</asp:ListItem> <asp:ListItem>Other</asp:ListItem> </asp:RadioButtonList> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> <br /> <br /> <asp:Button ID="Button1" runat="server" Text="Submit" onclick="Button1_Click" /> </div> <p> </p> </form> </body> </html> HOME PAGE ASPX CS: using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace WebApplication1 { public partial class WebForm1 : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { if (this.RadioButtonList1.SelectedValue == "BLUE") { Response.Redirect("Blue.aspx"); } else if (this.RadioButtonList1.SelectedValue == "RED") { Response.Redirect("Red.aspx"); } else { Response.Redirect("OtherColor.aspx?Data=" + Server.UrlEncode(TextBox1.Text)); } } protected void RadioButtonList1_SelectedIndexChanged(object sender, EventArgs e) { } } } OTHER PAGE: <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="OtherColor.aspx.cs" Inherits="WebApplication1.WebForm3" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <%var color = Server.UrlDecode(Request.QueryString["Data"]);%> <title></title> </head> <body> <form id="form1" runat="server"> <div> <asp:Label ID="Label1" runat="server" Text=color ForeColor=color></asp:Label> </div> </form> </body> </html> OTHER PAGE CS: using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace WebApplication1 { public partial class WebForm3 : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } } }Friday, November 4, 2011 10:38 AM
Answers
-
User-1889364718 posted
Hi ,
Why don't you do it from code behind of OtherColor.aspx. This code works fine for me .
using System.Drawing; public partial class Default4 : System.Web.UI.Page { protected string strColor; protected void Page_Load(object sender, EventArgs e) { strColor = Server.UrlDecode(Request.QueryString["Data"]); Label1.BackColor = Color.FromName(strColor); } }
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Friday, November 4, 2011 11:27 AM
All replies
-
User-2034757353 posted
I just added <%=Server.UrlDecode(Request.QueryString["Data"]) %> to the viewable text on the page and it does return the string entered in the textbox on the first page. Why won't it take it as input for text or ForeColor?
Friday, November 4, 2011 10:54 AM -
User-1889364718 posted
Hi ,
Why don't you do it from code behind of OtherColor.aspx. This code works fine for me .
using System.Drawing; public partial class Default4 : System.Web.UI.Page { protected string strColor; protected void Page_Load(object sender, EventArgs e) { strColor = Server.UrlDecode(Request.QueryString["Data"]); Label1.BackColor = Color.FromName(strColor); } }
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Friday, November 4, 2011 11:27 AM -
User-2034757353 posted
Took some tweaking to get desired behavior but this put me on the right track. Thank you!
Friday, November 4, 2011 12:23 PM