困惑中。。。
<script language="C#" runat="server">
void SubmitBtn_Click(Object Sender, EventArgs e)
{
//string SelectedIndex = DropDown1.SelectedIndex;
string SelectedText = DropDown1.SelectedItem.Text;
string SelectedValue = DropDown1.SelectedItem.Value;
Label1.Text="您选择的讨论区是:<font color=red>"+SelectedText+"<br></font>值为:<font color=red>"+SelectedValue+"</font>";
}
</script>
<html>
<head>
</head>
<body>
<b><font face="Verdana">DropDownList 示例</font></b>
<form runat=server>
<asp:DropDownList id=DropDown1 runat="server">
<asp:ListItem value="ASP.Net">ASP.Net区</asp:ListItem>
<asp:ListItem value="JSP">JSP区</asp:ListItem>
<asp:ListItem value="C#">C#区</asp:ListItem>
<asp:ListItem value="PHP">PHP区</asp:ListItem>
<asp:ListItem value="VBVC">VBVC区</asp:ListItem>
<asp:ListItem value="HTML">HTML区</asp:ListItem>
</asp:DropDownList>
<asp:button text="选择" OnClick="SubmitBtn_Click" runat=server/>
<p>
<asp:Label id=Label1 font-size="10pt" runat="server">
请选择一个讨论区
</asp:Label>
</form>
</body>
</html>
上面这段代码(index.aspx)可以运行,但是在vs.net 2003中我吧这一段:
void SubmitBtn_Click(Object Sender, EventArgs e)
{
//string SelectedIndex = DropDown1.SelectedIndex;
string SelectedText = DropDown1.SelectedItem.Text;
string SelectedValue = DropDown1.SelectedItem.Value;
Label1.Text="您选择的讨论区是:<font color=red>"+SelectedText+"<br></font>值为:<font color=red>"+SelectedValue+"</font>";
}
单击命令按钮后的处理事件的代码单独放在一个index.aspx.cs中,再运行的时候就提示出错了,实际上不是我想把这段代码单独放置,是因为我在编辑状态双击那个命令按钮的时候,vs.net 2003会自动出现一个index.aspx.cs的文件,请大家帮忙看看为什么会这样!