Solved

how come i cant access the request variables on an aspx page?

Posted on 2006-11-06
2
196 Views
Last Modified: 2010-04-16
i am trying to create a form and post a single value and read the value and its not working.
i have no idea why.

here is my page and codebehind:
########################################
page - title aspSUCKS.aspx
########################################
<%@ Page language="c#" Codebehind="aspSUCKS.aspx.cs" AutoEventWireup="false" Inherits="basketball.aspSUCKS" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
      <HEAD>
            <title>aspSUCKS</title>
      </HEAD>
      <body>
            <form id="Form1" method="post" runat="server" action="aspSucks.aspx">
                  
                  <input type="text" id="userName">
                  <asp:Button id="Button1"  runat="server" Text="SUBMIT"></asp:Button>
            </form>
      </body>
</HTML>
######################################
codebehind page:
######################################
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

namespace basketball
{
      /// <summary>
      /// Summary description for aspSUCKS.
      /// </summary>
      public class aspSUCKS : System.Web.UI.Page
      {
            protected System.Web.UI.WebControls.Button Button1;
      
            private void Page_Load(object sender, System.EventArgs e)
            {
                  // Put user code to initialize the page here
            }

            #region Web Form Designer generated code
            override protected void OnInit(EventArgs e)
            {
                  //
                  // CODEGEN: This call is required by the ASP.NET Web Form Designer.
                  //
                  InitializeComponent();
                  base.OnInit(e);
            }
            
            /// <summary>
            /// Required method for Designer support - do not modify
            /// the contents of this method with the code editor.
            /// </summary>
            private void InitializeComponent()
            {    
                  this.Button1.Click += new System.EventHandler(this.Button1_Click);
                  this.Load += new System.EventHandler(this.Page_Load);

            }
            #endregion

            private void Button1_Click(object sender, System.EventArgs e)
            {
                  Response.Write("Here is the variable userName-->" + Request.Form["userName"]);
                  Response.End();
            }
      }
}
0
Comment
Question by:richardsimnett
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 

Author Comment

by:richardsimnett
ID: 17882780
changed it from a <input type=text> to an <asp:TextBox
and it works fine.

points are still up for grabs if you can tell me why.

thanks.
0
 
LVL 16

Accepted Solution

by:
muzzy2003 earned 125 total points
ID: 17884467
input type="text" is an HTML control. It will only post as part of the form if you give it a name attribute. When you use an ASP.NET server-side control, it renders to the browser with an appropriate name attribute worked out from the control's ID, so that posts automatically. Try your first one with a name as well as an ID and it should work.
0

Featured Post

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

732 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question