0

我正在尝试使用 ASP(代码取自 W3 Schools)显示一个文本框,但是当我使用本地 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>
4

1 回答 1

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>
于 2013-06-26T23:25:32.203 回答