我有一个下拉列表,但缺少结束选项标记。这会导致站点无法针对XHTML 1.1进行W3C验证
这是我的HTML:
<select>
<option value="">Select...
<option value="val1">Value One
<option value="val2">Value Two
</select>
我希望如此:
<select>
<option value="">Select...</option>
<option value="val1">Value One</option>
<option value="val2">Value Two</option>
</select>
我尝试了HtmlSelect
和DropDownList
。我尝试添加ListItem
和数据绑定以填充它,但我每次都得到相同的HTML。
知道可能导致这种情况的原因吗?
修改
我使用的是.NET 3.5,该网站是Sitecore网站。
这是我的doctype声明:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
像这样填充:
HtmlSelect dropdown = new HtmlSelect();
dropdown.ID = _Data.ControlID;
List<DataCollectionItem> lisItemCollection = new List<DataCollectionItem>();
foreach (DataCollectionItem item in lisItemCollection)
dropdown.Items.Add(new ListItem(item.Text, item.Value));
也试过这个,结果相同:
dropdown.DataSource = lisItemCollection;
dropdown.DataTextField = "Text";
dropdown.DataValueField = "Value";
dropdown.DataBind();
浏览器文件:
Form.browser
<browsers>
<browser refID="Default">
<controlAdapters>
<adapter controlType="System.Web.UI.HtmlControls.HtmlForm" adapterType="Sitecore.Web.FormAdapter, Sitecore.Kernel" />
</controlAdapters>
</browser>
</browsers>
w3cValidator.browser
<browsers>
<!-- Browser capability file for the w3c validator
sample UA: "W3C_Validator/1.305.2.148 libwww-perl/5.803"
-->
<browser id="w3cValidator" parentID="default">
<identification>
<userAgent match="^W3C_Validator" />
</identification>
<capture>
<userAgent match="^W3C_Validator/(?'version'(?'major'\d+)(?'minor'\.\d+)\w*).*" />
</capture>
<capabilities>
<capability name="browser" value="w3cValidator" />
<capability name="majorversion" value="${major}" />
<capability name="minorversion" value="${minor}" />
<capability name="version" value="${version}" />
<capability name="w3cdomversion" value="1.0" />
<capability name="xml" value="true" />
<capability name="tagWriter" value="System.Web.UI.HtmlTextWriter" />
</capabilities>
</browser>
</browsers>
答案 0 :(得分:0)