11 Replies - 6849 Views - Last Post: 17 November 2010 - 11:40 AM Rate Topic: -----

#1 cyberjudge  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 30
  • Joined: 05-October 09

The Name 'my txtbox' does not exist in the current context

Posted 17 November 2010 - 09:40 AM

Can somebody help me figure this out. I am getting the does not exit in the current context error message on several of my textboxes that I added. The old ones that where added in the past are not showing the error, just the ones I added the past couple of days.

On my .aspx page I have:
<td class="style12">
     <asp:Label ID="Label10" runat="server" Font-Size="Small" Text="Address L1"></asp:Label>
</td>
<td class="style9">
     <asp:TextBox ID="txtAddress1" runat="server" Width="167px"></asp:TextBox>
</td>


Then in my .aspx.cs file I have:
 
if (txtAddress1.Text.ToString() != "" && txtAddress1.Text != " " && txtAddress1.Text != null)
{
     AddressL1.SqlValue = txtAddress1.Text;
}
else
{
     AddressL1.SqlValue = DBNull.Value;
}


all the txtAddress1.Text items in the cs file are showing the context error. Any help would be appreciated.

Is This A Good Question/Topic? 0
  • +

Replies To: The Name 'my txtbox' does not exist in the current context

#2 eclipsed4utoo  Icon User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1524
  • View blog
  • Posts: 5,957
  • Joined: 21-March 08

Re: The Name 'my txtbox' does not exist in the current context

Posted 17 November 2010 - 09:57 AM

would it be possible for you to post all of the HTML page code and all of the code-behind code? That's a really weird issue. Normally, it's caused by not having the runat="server" attribute, but you have it, so I am not totally sure.

There is nothing wrong with the code that you have shown, so it has got to be somewhere else.

and just a note, your if statement could be condensed to this..

AddressL1.SqlValue = DBNull.Value;

if (!string.IsNullOrEmpty(txtAddress1.Text.Trim()))
{
     AddressL1.SqlValue = txtAddress1.Text;
}


Was This Post Helpful? 0
  • +
  • -

#3 cyberjudge  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 30
  • Joined: 05-October 09

Re: The Name 'my txtbox' does not exist in the current context

Posted 17 November 2010 - 10:04 AM

Could the problem be because I copied one of the existing control, and pasted it in the new location then just renamed it and changed the properties? If need be I can post all my code but it is a lot of code.
Was This Post Helpful? 0
  • +
  • -

#4 eclipsed4utoo  Icon User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1524
  • View blog
  • Posts: 5,957
  • Joined: 21-March 08

Re: The Name 'my txtbox' does not exist in the current context

Posted 17 November 2010 - 10:08 AM

I copy controls all the time and I don't get this problem, so that shouldn't be the issue.

A lot of code is ok.
Was This Post Helpful? 0
  • +
  • -

#5 cyberjudge  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 30
  • Joined: 05-October 09

Re: The Name 'my txtbox' does not exist in the current context

Posted 17 November 2010 - 10:23 AM

Alright, I did nto think that was the problem but was the only thing I could think of. I have attached the cs file as a text doc and just removed the db connection info and email passwords. Please let me know if you see anything. if you need the aspx file let me know. Keep in mind the code is not all mind. I took this project over for my company after the previous programmer left so it is a mix bag of codding styles.

Attached File(s)


Was This Post Helpful? 0
  • +
  • -

#6 eclipsed4utoo  Icon User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1524
  • View blog
  • Posts: 5,957
  • Joined: 21-March 08

Re: The Name 'my txtbox' does not exist in the current context

Posted 17 November 2010 - 10:32 AM

can you also post the aspx file?
Was This Post Helpful? 0
  • +
  • -

#7 cyberjudge  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 30
  • Joined: 05-October 09

Re: The Name 'my txtbox' does not exist in the current context

Posted 17 November 2010 - 10:37 AM

here it is.

hmm, does not seem to let me post the file so here is the code:

<%@ page language="C#" autoeventwireup="true" CodeFile="Register.aspx.cs" inherits="Register" enableviewstatemac="false" enablesessionstate="True" enableeventvalidation="false" validaterequest="false" viewstateencryptionmode="Never" %>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Register Page</title>
    <style type="text/css">
                #wrapper 
        {
        	/*min-height:400px;*/
        	min-width:975px;
        }
        #header
        {
        	width:100%;
        	height:67px;
        }
        
        .loginstatus 
        {
        	height:33px;
        	padding-top:4px;
        	vertical-align:top;
        	color:#ffffff;
        	text-align:right;
        	/*background-image:url(images/header_slice.jpg);
        	background-repeat:repeat-x;*/
        	padding-right:10px;
        }
        
        body 
        {
        	margin:0px;
        	padding:0px;
        	font-family:Arial, Sans-Serif;
        	font-size:12px;
        }
        .style1
        {
            width: 100%;
            padding: 3px 3px 3px 3px;
        }
        .style6
        {
            width: 3%;
            border-left: 1px solid #333333;
        }
        .style7
        {
            width: 22%;
            padding-bottom: 3px;
            padding-top: 3px;
        }
        .style9
        {
            width: 23%;
            padding-bottom: 3px;
            padding-top: 3px;
        }
        .style10
        {
            font-size: xx-small;
            width: 25%;
            padding-bottom: 3px;
            padding-top: 3px;
        }
        .style11
        {
            width: 25%;
        }
        .style12
        {
            width: 25%;
        }
        .style13
        {
            width: 3%;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
        <div id="wrapper">
            <div id="header">
            </div>
        </div>
        <table style="width:100%; ">
            <tr>
                <td align="center">
                    <div style="width:601px; border: solid #aaaaaa 1px;">
                        <table cellpadding="0" cellspacing="0" style="width:580
                            px; text-align:left; height: 532px;">
                            <tr>
                                <td style="padding-top:6px; text-align: center;">
                                    <table class="style1">
                                        <tr>
                                            <td align="center">
                                                <img alt="" src="images/convergetracking_final.png" />
                                            </td>
                                        </tr>
                                    </table>                                            
                                </td>
                            </tr>
                            <tr>
                                <td style="padding-top:6px;">
                                    <br />
                                    <br />
                                    <asp:Label ID="Label7" runat="server" Text="Registration" Font-Bold="True" Font-Size="Large"></asp:Label>
                                    <br />
                                    <br />
                                    <asp:Label ID="Label17" runat="server" Text="&nbsp; Items marked with an astrics (*) are mandatory fields." Font-Size="Small" ForeColor="Red"></asp:Label>
                                    <br />
                                    <br />
                                    <table class="style1" cellpadding=0 cellspacing=0>
                                        <tr>
                                            <td colspan="2" style="text-align: center">
                                                <asp:Label ID="Label8" runat="server" Text="User Details" Font-Bold="True" Font-Size="Medium"></asp:Label>
                                            </td>
                                            <td class="style13">
                                                &nbsp;</td>
                                            <td class="style6">
                                                &nbsp;</td>
                                            <td colspan="2" style="text-align: center">
                                                <asp:Label ID="Label9" runat="server" Text="Company Details" Font-Bold="True" Font-Size="Medium"></asp:Label>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td class="style10">
                                                <asp:Label ID="Label1" runat="server" Text="First Name" Font-Size="Small"></asp:Label>
                                                *</td>
                                            <td class="style7">
                                                <asp:TextBox ID="firstName" runat="server"></asp:TextBox>
                                            </td>                                             
                                            <td class="style13">
                                                &nbsp;</td>                                             
                                            <td class="style6">
                                                &nbsp;</td>                                             
                                            <td class="style12">
                                                <asp:Label ID="lblCompany" runat="server" Font-Size="Small" Text="Company"></asp:Label>
                                                *</td>
                                            <td class="style9">
                                                <asp:TextBox ID="txtCompany" runat="server" Width="163px"></asp:TextBox>
                                            </td>                                        
                                        </tr>
                                        <tr>
                                            <td class="style11">
                                                <asp:Label ID="Label2" runat="server" Text="Last Name" Font-Size="Small"></asp:Label>
                                                *</td>
                                            <td class="style7">
                                                <asp:TextBox ID="lastName" runat="server"></asp:TextBox>
                                            </td>
                                            <td class="style13">
                                                &nbsp;</td>
                                            <td class="style6">
                                                &nbsp;
                                            </td>
                                            <td class="style12">
                                                <asp:Label ID="Label10" runat="server" Font-Size="Small" Text="Address L1"></asp:Label>
                                            </td>
                                            <td class="style9">
                                                <asp:TextBox ID="txtAddress1" runat="server" Width="167px"></asp:TextBox>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td class="style11">
                                                <asp:Label ID="Label3" runat="server" Text="User Name" Font-Size="Small"></asp:Label>
                                                *</td>
                                            <td class="style7">
                                                <asp:TextBox ID="userName" runat="server"></asp:TextBox>
                                            </td>
                                            <td class="style13">
                                                &nbsp;</td>
                                            <td class="style6">
                                                &nbsp;</td>
                                            <td class="style12">
                                                <asp:Label ID="Label11" runat="server" Font-Size="Small" Text="Address L2"></asp:Label>
                                            </td>
                                            <td class="style9">
                                                <asp:TextBox ID="address2" runat="server" Width="126px"></asp:TextBox>                                                
                                            </td>
                                        </tr>                                       
                                        <tr>
                                            <td class="style11">
                                                <asp:Label ID="Label4" runat="server" Text="Password" Font-Size="Small"></asp:Label>
                                                *</td>
                                            <td class="style7">
                                                <asp:TextBox ID="password" runat="server" TextMode="Password" Width="149px"></asp:TextBox>
                                            </td>
                                            <td class="style13">
                                                &nbsp;</td>
                                            <td class="style6">
                                                &nbsp;</td>
                                            <td class="style12">
                                                <asp:Label ID="Label12" runat="server" Font-Size="Small" Text="City & Prov/State"></asp:Label>
                                            </td>
                                            <td class="style9">
                                                <asp:TextBox ID="city" runat="server" Width="105px"></asp:TextBox>&nbsp;<asp:TextBox ID="province" 
                                                    runat="server" Width="41px"></asp:TextBox>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td class="style11">
                                                <asp:Label ID="Label6" runat="server" Text="Confirm Password" Font-Size="Small"></asp:Label>
                                                *</td>
                                            <td class="style7">
                                                <asp:TextBox ID="cPassword" runat="server" TextMode="Password" Width="149px"></asp:TextBox>
                                            </td>
                                            <td class="style13">
                                                &nbsp;</td>
                                            <td class="style6">
                                                &nbsp;</td>
                                            <td class="style12">
                                                <asp:Label ID="Label13" runat="server" Font-Size="Small" Text="Postal Code/Zip"></asp:Label>
                                            </td>
                                            <td class="style9">
                                                <asp:TextBox ID="zip" runat="server" style="height: 22px; width: 128px"></asp:TextBox>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td class="style11">
                                                <asp:Label ID="Label5" runat="server" Text="Email" Font-Size="Small"></asp:Label>
                                                *</td>
                                            <td class="style7">
                                                <asp:TextBox ID="email" runat="server" style="padding-right: 2px"></asp:TextBox>
                                            </td>
                                            <td class="style13">
                                                &nbsp;</td>
                                            <td class="style6">
                                                &nbsp;</td>
                                            <td class="style12">
                                                <asp:Label ID="Label14" runat="server" Font-Size="Small" Text="Office #"></asp:Label>
                                            </td>
                                            <td class="style9">
                                                <asp:TextBox ID="officePhone" runat="server" style="height: 22px; width: 128px"></asp:TextBox>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td class="style11">
                                                Mobile Number*
                                            </td>
                                            <td class="style7">
                                                <asp:TextBox ID="txtPhoneNumber" runat="server"></asp:TextBox>
                                            </td>
                                            <td class="style13">
                                                &nbsp;</td>
                                            <td class="style6">
                                                &nbsp;</td>
                                            <td class="style12">
                                                <asp:Label ID="Label15" runat="server" Font-Size="Small" Text="Fax #"></asp:Label>
                                            </td>
                                            <td class="style9">
                                                <asp:TextBox ID="fax" runat="server" style="height: 22px; width: 128px"></asp:TextBox>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td class="style11">
                                                Activation Code    
                                            </td>
                                            <td class="style7">
                                                <asp:TextBox ID="txtActivation" runat="server"></asp:TextBox>
                                            </td>
                                            <td class="style13">
                                                &nbsp;</td>
                                            <td class="style6">
                                                &nbsp;</td>
                                            <td class="style12">
                                                <asp:Label ID="Label16" runat="server" Font-Size="Small" Text="Company URL"></asp:Label>
                                            </td>
                                            <td class="style9">
                                                <asp:TextBox ID="url" runat="server" style="height: 22px; width: 128px"></asp:TextBox>
                                            </td>
                                        </tr>
                                    </table>                                
                                    <br />
                                    <asp:Label ID="ErrorText" runat="server" ForeColor="Red"></asp:Label>
                                    <br />
                                    <br />
                                    <asp:Button ID="CreateUser" runat="server" onclick="CreateUser_Click" style="text-align: center" Text="Create User" />
                                </td>
                            </tr>
                            <tr>
                                <td style="padding:5px;">
                                    <br />
                                    <p>
                                        This site is used by  <a href="http://www.convergewireless.com/p31/My-Mileage-Genie/product_info.html">MyMileageGenie</a> subscribers. Subscribers are permitted to save up to, and report on, up to 12 months worth of data. 
                                        MileageGeniePro.com provides users with a <b>FREE</b> 14 day trial. If you subscribe to 
                                        MielageGeniePro.com add the Activation Code emailed to you when you purchased
                                    </p>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    &nbsp;
                                </td>
                            </tr>
                        </table>
                    </div>
                </td>
            </tr>
        </table>    
    </form>
</body>
</html>


Was This Post Helpful? 0
  • +
  • -

#8 eclipsed4utoo  Icon User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1524
  • View blog
  • Posts: 5,957
  • Joined: 21-March 08

Re: The Name 'my txtbox' does not exist in the current context

Posted 17 November 2010 - 10:44 AM

Have you tried closing Visual Studio and then opening it again? I don't see why you are getting the errors.
Was This Post Helpful? 0
  • +
  • -

#9 cyberjudge  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 30
  • Joined: 05-October 09

Re: The Name 'my txtbox' does not exist in the current context

Posted 17 November 2010 - 10:56 AM

just tried closing vs and reoppening, still no go. I'm going to try restarting my laptop in a second.
Was This Post Helpful? 0
  • +
  • -

#10 cyberjudge  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 30
  • Joined: 05-October 09

Re: The Name 'my txtbox' does not exist in the current context

Posted 17 November 2010 - 11:32 AM

just did the reboot and still no go. Thi is most confusing.
Was This Post Helpful? 0
  • +
  • -

#11 cyberjudge  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 30
  • Joined: 05-October 09

Re: The Name 'my txtbox' does not exist in the current context

Posted 17 November 2010 - 11:37 AM

OK, I ended up figuring out the problem and fixing it. It ended up being that there were files named the same with .old at the end of them in the folder. When I moved those .old files out the errors went away. Must have been something within those .old files that caused the issues.
Was This Post Helpful? 0
  • +
  • -

#12 eclipsed4utoo  Icon User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1524
  • View blog
  • Posts: 5,957
  • Joined: 21-March 08

Re: The Name 'my txtbox' does not exist in the current context

Posted 17 November 2010 - 11:40 AM

*facepalm*...the previous developer was amazing. [/sarcasm]
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1