使用C#将自定义属性添加到HTML输入元素 [英] Add custom attribute to an HTML input element with C#
本文介绍了使用C#将自定义属性添加到HTML输入元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用以下方法将自定义属性添加到复选框:
I'm using the following method to add a custom attribute to a check box:
CheckBox chkBx = new CheckBox();
chkBx.ID = "chk" + n;
chkBx.Attributes["itemname"] = strtemPath;
但是,结果是我得到了以下HTML:
But as a result I'm getting the following HTML:
<span itemname="Some folder"><input id="MainContent_chk0" type="checkbox" name="MasterPg$MainContent$chk0" /></span>
我期望在哪里:
<input id="MainContent_chk0" type="checkbox" name="MasterPg$MainContent$chk0" itemname="Some folder" />
有什么主意如何更正C#代码以获得我期望的结果?
Any idea how to correct the C# code to get my expected result?
推荐答案
尝试类似
chkBx.InputAttributes.Add("itemname", strtemPath);
这篇关于使用C#将自定义属性添加到HTML输入元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文