C# 在从头创建的项目中,DropDownCheckBoxList中没有值字段,但在下载包项目中存在
我已从其下载了DropDownCheckBoxList控件。C# 在从头创建的项目中,DropDownCheckBoxList中没有值字段,但在下载包项目中存在,c#,asp.net,webforms,C#,Asp.net,Webforms,我已从其下载了DropDownCheckBoxList控件。 我在Visual Studio 2012中使用文件->新建->网站创建了新的网站,并将dll添加到引用中 然后在Default.aspx中,我添加了以下示例代码: <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> <%@ Register TagPrefix="asp" Na
我在Visual Studio 2012中使用文件->新建->网站创建了新的网站,并将dll添加到引用中 然后在Default.aspx中,我添加了以下示例代码:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%@ Register TagPrefix="asp" Namespace="Saplin.Controls" Assembly="DropDownCheckBoxes" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"> </script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:DropDownCheckBoxes ID="checkBoxes2" runat="server">
<Style SelectBoxWidth="300" />
<Items>
<asp:ListItem Text="Option 1" Value="1" />
<asp:ListItem Text="Option 2" Value="2" />
</Items>
</asp:DropDownCheckBoxes>
</div>
</form>
</body>
</html>
启动调试器后,会显示我的网站,但在Chrome中使用element inspector时,我注意到DropDownCheckBox没有呈现复选框的值字段:
DropDownCheckBoxList附带的下载包中有一个示例项目,当我启动它时,我可以看到值字段被呈现:
这是我第四个小时试图找出我的代码出了什么问题我应该如何创建网站或Web应用程序,以呈现值字段?在又搜索了4个小时后,我找到了非常棒的答案: 将以下条目添加到
web.config
中时,不会呈现值
<pages controlRenderingCompatibilityVersion="3.5">
因此,删除它立即解决了我的问题。控件不是应该在
text
属性中呈现文本,而是将value
属性中的值返回给代码吗?我使用了下载包中提供的示例代码。这里是到官方回购和资源的链接:我最大的问题是要弄清楚为什么在下载包的项目中我得到了值字段,而在从头开始的项目构建中这个字段不是there@Sean-知道我为什么会得到不同的结果吗?