10-12-2005, 09:49
|
|
|
חבר מתאריך: 10.12.05
הודעות: 545
|
|
בעיה מוזרה בקוד של ASP.NET
להלן קטע הקוד:
קוד:
<%@ Page Language ="VB" %>
<%@ Import Namespace="system.drawing" %>
<script runat="server" >
Sub namehandler(ByVal obj As Object, ByVal e As EventArgs)
lblmessage.Text = tbname1.text & ", select a color: "
End Sub
Sub listhandler(ByVal obj As Object, ByVal e As EventArgs)
lbcolor.BackColor = Color.FromName(obj.selecteditem.text)
End Sub
</script>
<html> <body >
<form>
<asp:TextBox ID="tbname1" OnTextChanged ="namehandler" AutoPostBack ="true" runat="server"></asp:TextBox>
<asp:Label ID="lblmessage" runat ="server" Text="select a color" ></asp:Label>
<p></p>
<asp:ListBox ID="lbcolor" runat ="server" OnSelectedIndexChanged ="listhandler" AutoPostBack ="true" Height="135px" >
<asp:ListItem>Red</asp:ListItem>
<asp:ListItem>Blue</asp:ListItem>
<asp:ListItem>Green</asp:ListItem>
<asp:ListItem>White</asp:ListItem>
</asp:ListBox>
</form>
</body></html>
אולם כשאני מנסה להריץ אותו מתקבלת השגיאה הבא:
ציטוט:
Control 'tbname1' of type 'TextBox' must be placed inside a form tag with runat=server.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Web.HttpException: Control 'tbname1' of type 'TextBox' must be placed inside a form tag with runat=server.
|
אני אשמח אם מישהו יעזור לי תודה.
הקוד אותו אני מנסה להריץ הוא מתוך ספר ואני משתמש בMicrosoft Visual Studio 2005 לכתיבת הקוד.
נ.ב.
אני רק מתחיל בASP.NET
נערך לאחרונה ע"י alex188 בתאריך 10-12-2005 בשעה 09:53.
|