首页 > 代码库 > 前台自动生成控件

前台自动生成控件

前台:

<div id="location" runat="server">
</div>

后台:
    /// <summary> /// 自动生成button控件 /// </summary> public void GenerateControls() { StringBuilder strbHTMl = new StringBuilder(); strbHTMl.Append("<table>"); int count = 0; for (int i=0;i<100;i++) {//设置一行显示的库位个数 if (count == 0) { strbHTMl.Append("<tr>"); } if (count == 9) { strbHTMl.Append("</tr>"); count = 0; } strbHTMl.Append("<td>");    strbHTMl.Append("<input id=\"button" + garageNumber + "\" type=\"button\" style=\"background:" + color + ";color:white;\" value=http://www.mamicode.com/"" + garageNumber + "\" class=\"Button\" onclick=\" window.showModalDialog(‘../LocationStatus.aspx/?Enter=" + garageNumber + "‘, ‘‘, ‘dialogHeight=30;dialogWidth=60;dialogTop=30;dialogLeft=465;center=yes;resizable:no;scroll:no;status:no;help=no‘)\" \">"); //strbHTMl.Append("<input id=\"button" + garageNumber + "\" type=\"button\" style=\"background:" + color + ";color:white;\" value=http://www.mamicode.com/"" + garageNumber + "\" class=\"Button\" onclick=\"window.open(‘../LocationStatus.aspx/?Enter=" + garageNumber + "‘, ‘newwindow‘, ‘height=450, width=900, top=300, left=490, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=n o, status=no‘)\" \">"); strbHTMl.Append("</td>"); count++; } strbHTMl.Append("</table>"); location.InnerHtml = strbHTMl.ToString(); }

 

前台自动生成控件