Link to home
Start Free TrialLog in
Avatar of richardsimnett
richardsimnett

asked on

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

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();
            }
      }
}
Avatar of richardsimnett
richardsimnett

ASKER

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.
ASKER CERTIFIED SOLUTION
Avatar of muzzy2003
muzzy2003

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial