vb.net 未声明。由于其保护级别,它可能无法访问

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/22549325/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-17 17:10:27  来源:igfitidea点击:

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

vb.net

提问by user2172157

Protected Sub btnAddSubmit_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnAddSubmit.Click
    Dim SQLStatement As String = "INSERT INTO account(firstname, lastname, uname, pass, type)" & " VALUES ('" & fname.Value.ToString & "','" & lname.Value.ToString & "','" & username.Value.ToString & "','" & password.Value.ToString & "','" & Type.Value.ToString & "')"
    SaveNames(SQLStatement)
    fname.Value = ""
    lname.Value = ""
    username.Value = ""
    password.Value = ""
    Type.Value = ""

All the fname.Value.ToString, lname.Value.ToString, uname.Value.ToString, password.Value.ToString, type.Value.ToString is showing an error of

所有 fname.Value.ToString, lname.Value.ToString, uname.Value.ToString, password.Value.ToString, type.Value.ToString 都显示错误

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

未声明。由于其保护级别,它可能无法访问。

These are textbox

这些是文本框

        <div class="pure-control-group">
        <label for="firstname">First Name</label>
        <input runat="server" id="fname" type="text" placeholder="Firstname">
    </div>
    <div class="pure-control-group">
        <label for="lastname">Last Name</label>
        <input runat="server" id="lname" type="text" placeholder="Lastname">
    </div>
    <div class="pure-control-group">
        <label for="name">Username</label>
        <input runat="server" id="username" type="text" placeholder="Username">
    </div>
    <div class="pure-control-group">
        <label for="password">Password</label>
        <input runat="server" id="password" type="password" placeholder="Password">

回答by Codemunkeee

You should probably use the .Textproperty instead of 'value'

您可能应该使用该.Text属性而不是“值”

fname.Text = ""
...

回答by Ashish Gupta

If the code behind class is not declared public, try making that public.

如果类背后的代码未声明为公开,请尝试将其公开。