Problems referencing a textbox in demo

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Problems referencing a textbox in demo

Guest-1072
hi,
i created a c# .net website, and i have the demo page running perfectly...modified code to save the files on the server.  I need to add a few fields to the form for additional user input.   i added (to the demo page)  a (.net) text box.  However, when i try to reference this control in the code behind file, i get a build error: "The name 'txtFirstName' does not exist in the current context".

i created this in VSD as a "website" and the only files in the project are demo.aspx and demo.aspx.cs (and associated neatupload files and folders) .  here is a link to a graphic of the solution explorer window

Code from demo.aspx:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ Page language="c#" Src="Demo.aspx.cs"  AutoEventWireup="false" Inherits="Brettle.Web.NeatUpload.Demo" %>
<%@ Register TagPrefix="Upload" Namespace="Brettle.Web.NeatUpload" Assembly="Brettle.Web.NeatUpload" %>

<html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
      
    </head>
    <body>
        <form id="uploadForm" runat="server">
        <Upload:UnloadConfirmer runat="server"/>
            <h1>Dropbox</h1>
           
            <p>
    First Name:
    <asp:TextBox ID="txtFirstName" runat="server"  ></asp:TextBox>

------------ etc ------------------
The code behind file definition begins like:
using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.IO;
using System.Net.Mail;
using System.Drawing;
using System.Configuration;

namespace Brettle.Web.NeatUpload
{
    public class Demo : System.Web.UI.Page
    {   
     
        protected void submitButton_Click(object sender, EventArgs e)
        {
           <!-- blah...stuff -->
         bodyPre.InnerText +=  txtFirstName.Text;
       // error on this line The name 'txtFirstName' does not exist in the current context

         }


i thought perhaps the web control might need to be fully qualified, but i can't get that to work either.  any help you can provide is greatly appreciated.

thanks
michaele
Reply | Threaded
Open this post in threaded view
|

Re: Problems referencing a textbox in demo

Dean Brettle
Administrator
The demo is designed to be compatible with asp.net 1.1. As a result, it does not use partial classes. So, all controls need to be explicitly declared as members in Demo.aspx.cs. Of course, if you create a new page, you can use partial classes and NeatUpload will still work. --Dean
Reply | Threaded
Open this post in threaded view
|

Re: Problems referencing a textbox in demo

Guest-1072
ok, thanks