问题描述
问题1和问题2不是一个程序中的问题.问题1:运行时,语句中<asp:ListBoxid="ListBox1"runat="server"onSelectedIndexChanged="listbox1_selectedindexchanged"><asp:listitem="listi"value="str"selected="true">字符串</asp:listitem></asp:ListBox>的代码<asp:listitem="listi"value="str"selected="true">字符串</asp:listitem>出现如下错误提示:Literalcontent('<asp:listitem="listi"value="str"selected="true">字符串</asp:listitem>)isnotallowedwithina'System.Web.UI.WebControls.ListItemCollection'.问题2在<scriptrunat="server">subbutton1_click(senderasobject,easeventargs)Label2.text="通过验证!"endsub</script>中的"通过验证!"字符如何在<html><head></head><body><formrunat="server"><asp:Labelid="Label2"runat="server"></asp:Label></form></body></html>中Label控件显示出来????
解决方案
解决方案二:
<asp:ListBoxid="ListBox1"runat="server"onSelectedIndexChanged="listbox1_selectedindexchanged"><asp:listitem="listi"value="str"selected="true">字符串</asp:listitem></asp:ListBox>==<asp:ListBoxid="ListBox1"runat="server"onSelectedIndexChanged="listbox1_selectedindexchanged"><asp:listitemvalue="str"selected="true">字符串</asp:listitem></asp:ListBox>
解决方案三:
<scriptrunat="server">subbutton1_click(senderasobject,easeventargs)Label2.text="通过验证!"endsub</script><html><head></head><body><formrunat="server"><asp:Labelid="Label2"runat="server"></asp:Label></form></body></html>修改为以下代码,并点击Button1===<scriptrunat="server">subbutton1_click(senderasobject,easeventargs)Label2.text="通过验证!"endsub</script><html><head></head><body><formrunat="server"><asp:ButtonID="Button1"runat="server"Text="Button"OnClick="button1_click"/><asp:Labelid="Label2"runat="server"></asp:Label></form></body></html>