Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'txtName' is not declared. It may be inaccessible due to its protection level

Tags:

asp.net

After putting a textbox on my page when I compile it I get the above error:

'txtName' is not declared. It may be inaccessible due to its protection level.

This is happening when I try to read the value of the textbox in the codebehind page.

I'm not sure what's causing this...any ideas?

In the aspx file I have:

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="signup.aspx.vb" Inherits="signup" %>

In the codebehind aspx.vb file I have:

Imports System.Data.SqlClient
Partial Class signup
    Inherits System.Web.UI.Page

    Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmit.Click 
like image 394
thegunner Avatar asked May 30 '11 16:05

thegunner


1 Answers

Ok, I have this resolved now. It was becuase I had renamed a copy of the .aspx file and which still using the newer versions code behind file.

The code behind file was looking for txtName.text but on the older version of the .aspx file txtName didnt exist!

I have excluded the older version of the page from the project and it appears to run ok now.

Thanks everyone for you help.

like image 58
thegunner Avatar answered Oct 18 '22 12:10

thegunner