我的代码如下:
请问我这样写为什么执行不过,是不是不能在一个WEB窗体中加入两个FORM呢?如果可以我的代码应该如何改写?在此请大家务必帮忙,万分感谢!<%@ Page Language="C#" %>
<script runat="server"> void Page_Load() { string SubjectsSelected=""; if(Page.IsPostBack) mylabel.Text="the subject which you have slected was: "+droplist1.SelectedItem.Value; if(box1.Items[0].Selected==true)
{
SubjectsSelected=SubjectsSelected+box1.Items[0].Text+"<br/>"; } if(box1.Items[1].Selected==true)
{
SubjectsSelected=SubjectsSelected+box1.Items[1].Text+"<br/>"; } if(box1.Items[2].Selected==true)
{
SubjectsSelected=SubjectsSelected+box1.Items[2].Text+"<br/>"; } if(box1.Items[3].Selected==true)
{
SubjectsSelected=SubjectsSelected+box1.Items[3].Text+"<br/>"; } if(SubjectsSelected!=""){ mylabel1.Text="The subject which you have slected was: "+SubjectsSelected; }
else
{
SubjectsSelected="";
}
}</script>
<html>
<head>
</head>
<body>
<form id="myform"runat="server">
<asp:Label id="mylabel" runat="server"></asp:Label><br><br>
which subject do you like best?<br />
<asp:dropdownlist id="droplist1" runat="server">
<asp:listitem id="listitem1" text="Maths" />
<asp:listitem id="listitem2" text="English" />
<asp:listitem id="listitem3" text="Computer Technology" />
</asp:dropdownlist>
<input type="submit" value="提交"/>
</form> <form id="myform1" runat="server">
<asp:Label id="mylabel1" runat="server"/><br><br>
which subjects do you selected this term?<br><br>
<asp:listbox id="box1" runat="server" selectionmode="multiple">
<asp:listitem id="subject1" text="Maths"/>
<asp:listitem id="subject2" text="English"/>
<asp:listitem id="subject3" text="Red Hat Linux"/>
<asp:listitem id="subject4" text="Computer System"/>
</asp:listbox>
<input type="submit" value="提交"/>
</form></body>
</html>
请问我这样写为什么执行不过,是不是不能在一个WEB窗体中加入两个FORM呢?如果可以我的代码应该如何改写?在此请大家务必帮忙,万分感谢!<%@ Page Language="C#" %>
<script runat="server"> void Page_Load() { string SubjectsSelected=""; if(Page.IsPostBack) mylabel.Text="the subject which you have slected was: "+droplist1.SelectedItem.Value; if(box1.Items[0].Selected==true)
{
SubjectsSelected=SubjectsSelected+box1.Items[0].Text+"<br/>"; } if(box1.Items[1].Selected==true)
{
SubjectsSelected=SubjectsSelected+box1.Items[1].Text+"<br/>"; } if(box1.Items[2].Selected==true)
{
SubjectsSelected=SubjectsSelected+box1.Items[2].Text+"<br/>"; } if(box1.Items[3].Selected==true)
{
SubjectsSelected=SubjectsSelected+box1.Items[3].Text+"<br/>"; } if(SubjectsSelected!=""){ mylabel1.Text="The subject which you have slected was: "+SubjectsSelected; }
else
{
SubjectsSelected="";
}
}</script>
<html>
<head>
</head>
<body>
<form id="myform"runat="server">
<asp:Label id="mylabel" runat="server"></asp:Label><br><br>
which subject do you like best?<br />
<asp:dropdownlist id="droplist1" runat="server">
<asp:listitem id="listitem1" text="Maths" />
<asp:listitem id="listitem2" text="English" />
<asp:listitem id="listitem3" text="Computer Technology" />
</asp:dropdownlist>
<input type="submit" value="提交"/>
</form> <form id="myform1" runat="server">
<asp:Label id="mylabel1" runat="server"/><br><br>
which subjects do you selected this term?<br><br>
<asp:listbox id="box1" runat="server" selectionmode="multiple">
<asp:listitem id="subject1" text="Maths"/>
<asp:listitem id="subject2" text="English"/>
<asp:listitem id="subject3" text="Red Hat Linux"/>
<asp:listitem id="subject4" text="Computer System"/>
</asp:listbox>
<input type="submit" value="提交"/>
</form></body>
</html>
你去掉另一个FORM 的 ID 和 RUNAT 属性试试