?
Solved

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

Posted on 2006-11-06
2
Medium Priority
?
198 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 500 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses
Course of the Month14 days, 22 hours left to enroll

770 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