ASP.NET报错:CS1061: 'System.Web.UI.HtmlControls.HtmlSelect' does not contain a definition for 'val
ASP.NET编写的小页面源代码如下:<%@PageLanguage="C#"%><html><headrunat=server><title>test2.aspx</t...
ASP.NET编写的小页面源代码如下:
<%@ Page Language="C#" %>
<html>
<head runat=server>
<title>test2.aspx</title>
</head>
<body>
<form method="post" runat="server">
<select id="select1" runat="server">
<option value>Red</option>
<option value>Blue</option>
<option value>Green</option>
</select>
<input type="submit" value="Submit" runat="server">
</form>
<div>
<font color=<%=select1.value%>>
You Selected Color : <%= select1.value%>
</font>
</div>
</body>
</html>
执行页面报错:CS1061: 'System.Web.UI.HtmlControls.HtmlSelect' does not contain a definition for 'value' and no extension method 'value' accepting a first argument of type 'System.Web.UI.HtmlControls.HtmlSelect' could be found (are you missing a using directive or an assembly reference?)
请教各位高师指点,谢谢!!!! 展开
<%@ Page Language="C#" %>
<html>
<head runat=server>
<title>test2.aspx</title>
</head>
<body>
<form method="post" runat="server">
<select id="select1" runat="server">
<option value>Red</option>
<option value>Blue</option>
<option value>Green</option>
</select>
<input type="submit" value="Submit" runat="server">
</form>
<div>
<font color=<%=select1.value%>>
You Selected Color : <%= select1.value%>
</font>
</div>
</body>
</html>
执行页面报错:CS1061: 'System.Web.UI.HtmlControls.HtmlSelect' does not contain a definition for 'value' and no extension method 'value' accepting a first argument of type 'System.Web.UI.HtmlControls.HtmlSelect' could be found (are you missing a using directive or an assembly reference?)
请教各位高师指点,谢谢!!!! 展开
展开全部
好像是你的value没有定义属性和方法,修改如下:
<%@ Page Language="C#" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>test2.aspx</title>
</head>
<body>
<form id="Form1" method="post" runat="server">
<select id="select1" runat="server">
<option value="red">Red</option>
<option value="blue">Blue</option>
<option value="green">Green</option>
</select>
<input id="Submit1" type="submit" value="Submit" runat="server"/>
</form>
<div>
<font> color="<%=select1.Value%>
you select color: <%= select1.Value%>"
</font>
</div>
</body>
</html>
<%@ Page Language="C#" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>test2.aspx</title>
</head>
<body>
<form id="Form1" method="post" runat="server">
<select id="select1" runat="server">
<option value="red">Red</option>
<option value="blue">Blue</option>
<option value="green">Green</option>
</select>
<input id="Submit1" type="submit" value="Submit" runat="server"/>
</form>
<div>
<font> color="<%=select1.Value%>
you select color: <%= select1.Value%>"
</font>
</div>
</body>
</html>
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询