你可以用runat="server"的 Html control实现你的要求:
......
protected System,Web.UI.HtmlControls.HtmlInputCheckBox chkBox;
......chkBox.Attributes["myAttribute"]="kevin";

解决方案 »

  1.   

    to  yunhi():结果与chkBox.Attributes.Add("myAttribute","kevin");是一样的
      

  2.   

    还有的是:就算是在.aspx中如下指定:
    <asp:CheckBox id="chkBox" runat="server" myAttribute="kevin">结果生成的html也是:
    <span myAttribute='kevin'><input type=checkbox id=chkBox onclick="clickFunc();"></span>惨。
      

  3.   

    System.Web.UI.HtmlTextWriter myHtmlTextWriter  = new System.Web.UI.HtmlTextWriter("myAttribute='kevin'");
    chkBox.Attributes.AddAttributes(myHtmlTextWriter);test...
      

  4.   

    请注意,我说的是runat="server"的 Html control
    在aspx页面文件中是:
    <input id="chkBox" type="checkbox" runat="server">
      

  5.   

    to yunhi():你是对的,我没有留心这个问题。没想到将webcontrol换成htmlcontrol就解决了。真的谢谢了。:)