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

后端 未结 13 1618
暖寄归人
暖寄归人 2020-12-15 19:22

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.

13条回答
  •  生来不讨喜
    2020-12-15 19:49

    This is what happened at my case.

    -I have declared the variable at behind code

    Protected Friend sMessage As String = ""
    

    -Then the aspx : <%=sMessage%>

    this case appears (visual studio 2015 - asp webform project)

    Then I try to :

    -clean solution

    -Rebuild

    Then the problem is gone

    If the clean solution and rebuild does not work

    try to clean the obj directory
    

    If the variable is asp component

    make sure runat="server" at the aspx file

提交回复
热议问题