ASP文本框不可见

时间:2013-06-26 22:23:06

标签: asp.net textbox

我正在尝试使用ASP显示文本框(代码来自W3学校)但是当我使用本地IIS服务器运行网站时,我只看到“输入您的名字:”标签。

<script runat="server">
Sub submit(sender As Object, e As EventArgs)
   lbl1.Text="Your name is " & txt1.Text
End Sub
</script>

<!DOCTYPE html>
<html>
<body>

<form runat="server">
Enter your name:
<asp:TextBox id="txt1" runat="server" />
<asp:Button OnClick="submit" Text="Submit" runat="server" />
<p><asp:Label id="lbl1" runat="server" /></p>
</form>

</body>
</html>

注意:这是一个坚持使用ASP的人的项目,所以我不能做PHP而且我不懂ASP。

感谢。

编辑这是呈现的HTML

<html><head><script runat="server">
Sub submit(sender As Object, e As EventArgs)
   lbl1.Text="Your name is " & txt1.Text
End Sub
</script>



</head><body>

<form runat="server">
Enter your name:
<asp:textbox id="txt1" runat="server">
<asp:button onclick="submit" text="Submit" runat="server">
<p><asp:label id="lbl1" runat="server"></asp:label></p>



</asp:button></asp:textbox></form></body></html>

1 个答案:

答案 0 :(得分:1)

你需要语言;在你的情况下它是VB。我假设您使用的是Visual Studio。

<%@ Page Language="VB" AutoEventWireup="true"  %>

<!DOCTYPE html>
<html>
<body>

    <script runat="server">
        Public Sub submit(sender As Object, e As EventArgs)
            lbl1.Text = "Your name is " + txt1.Text
        End Sub
    </script>

    <form id="Form1" runat="server">
        Enter your name:
        <asp:TextBox ID="txt1" runat="server" />
        <asp:Button ID="Button1" OnClick="submit" Text="Submit" runat="server" />
        <p>
            <asp:Label ID="lbl1" runat="server" />
        </p>
    </form>

</body>
</html>