Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
794 views
in Technique[技术] by (71.8m points)

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

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 
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...