C#/ASP Updating ASP:Label Problem
-
Can someone provide an example where you get a value from the query string, use it somehow, and update the values of some form fields? Basically, I want to have a URL ( .../page1.aspx?ID=345 ) that specifies some value. Then, I want to extract that value and display it in an ASP field. I can extract the value and display it using Response.Write, but can't seem to make it update the ASP:Label. :confused: ======= page1.aspx ======== <%@ Page Language="C#" ContentType="text/html" ResponseEncoding="iso-8859-1" %> Sample
<% // This statement works. Response.Write("Response Write: " + Request.QueryString["ID"]); // This does not work. SetValue(Request.QueryString["ID"]); // This does not work. Message.Text = Request.QueryString["ID"]; %> void SetValue(String sValue) { Message.Text = "Received " + sValue; } =========================== Thanks for any pointers. --G Modified: Forgot to check the box.
-
Can someone provide an example where you get a value from the query string, use it somehow, and update the values of some form fields? Basically, I want to have a URL ( .../page1.aspx?ID=345 ) that specifies some value. Then, I want to extract that value and display it in an ASP field. I can extract the value and display it using Response.Write, but can't seem to make it update the ASP:Label. :confused: ======= page1.aspx ======== <%@ Page Language="C#" ContentType="text/html" ResponseEncoding="iso-8859-1" %> Sample
<% // This statement works. Response.Write("Response Write: " + Request.QueryString["ID"]); // This does not work. SetValue(Request.QueryString["ID"]); // This does not work. Message.Text = Request.QueryString["ID"]; %> void SetValue(String sValue) { Message.Text = "Received " + sValue; } =========================== Thanks for any pointers. --G Modified: Forgot to check the box.
-
I know my example didn't account for all error conditions, but for examples sake, assuming a value is passed it, I'd like to update the ASP:Label called Message. I modified the code a little from what is above: <% // This statement works. Response.Write("Response Write: " + Request.QueryString["ID"]); // This does not work. Message.Text = "Some VALID string"; %> and can't get the Message.Text line to display.
-
I know my example didn't account for all error conditions, but for examples sake, assuming a value is passed it, I'd like to update the ASP:Label called Message. I modified the code a little from what is above: <% // This statement works. Response.Write("Response Write: " + Request.QueryString["ID"]); // This does not work. Message.Text = "Some VALID string"; %> and can't get the Message.Text line to display.
-
Marcie, Thanks for the example, but it didn't work for me. Changing my code (in the <% %>) to: // This statement works. Response.Write("Response Write: " + Request.QueryString["ID"]); // This statement does not work. Message.Text = (string) Request.QueryString["ID"].ToString(); generates the following output: ==== Response Write: 342 ====
-
Marcie, Thanks for the example, but it didn't work for me. Changing my code (in the <% %>) to: // This statement works. Response.Write("Response Write: " + Request.QueryString["ID"]); // This statement does not work. Message.Text = (string) Request.QueryString["ID"].ToString(); generates the following output: ==== Response Write: 342 ====
-
Sure, no problem. I access this at http://localhost/page.aspx?ID=234 ======== <%@ Page Language="C#" ContentType="text/html" ResponseEncoding="iso-8859-1" debug="true" %> Sample <% // This statement works. Response.Write("Response Write: " + Request.QueryString["ID"]); // This statement does not work. Message.Text = (string) Request.QueryString["ID"].ToString(); %> =============
-
Sure, no problem. I access this at http://localhost/page.aspx?ID=234 ======== <%@ Page Language="C#" ContentType="text/html" ResponseEncoding="iso-8859-1" debug="true" %> Sample <% // This statement works. Response.Write("Response Write: " + Request.QueryString["ID"]); // This statement does not work. Message.Text = (string) Request.QueryString["ID"].ToString(); %> =============
-
Marcie, Thanks so much. It is working now -- my new code is below. --G ===== <%@ Page Language="C#" ContentType="text/html" ResponseEncoding="iso-8859-1" debug="true" %> Sample Passed Value:
protected void Page_Load(Object Source, EventArgs E) { // This works now! Message.Text = (string) Request.QueryString["ID"].ToString(); } =====