后台生成的【checkbox】怎么给name指定值
C# code Literal littxt = new Literal(); Literal litti = new Literal(); //CheckBoxList che = new CheckBoxList();//复选框多选择 CheckBoxList cbk = new CheckBoxList(); cbk.ID = "cbk" + i.ToString(); littxt.Text = "<input type='hidden' name='db_" + bie.ToString() + "' id='db_" + bie + "' value='' answer='" + Server.HtmlEncode(sdr["rightAns"].ToString()) + "'/>" + "<div class='result' id='result_" + bie.ToString() + "' >" + i.ToString() + "、" + Server.HtmlEncode(sdr["testContent"].ToString()); litti.Text = "</div>"; littcookie["littxt"] += HttpUtility.UrlEncode(littxt.Text + "|"); littcookie["acbk"] += HttpUtility.UrlEncode(sdr["testAns1"].ToString()) + "|"; littcookie["bcbk"] += HttpUtility.UrlEncode(sdr["testAns2"].ToString()) + "|"; littcookie["ccbk"] += HttpUtility.UrlEncode(sdr["testAns3"].ToString()) + "|"; littcookie["dcbk"] += HttpUtility.UrlEncode(sdr["testAns4"].ToString()) + "|"; cbk.Items.Add("A. " + Server.HtmlEncode(sdr["testAns1"].ToString())); cbk.Items.Add("B. " + Server.HtmlEncode(sdr["testAns2"].ToString())); cbk.Items.Add("C. " + Server.HtmlEncode(sdr["testAns3"].ToString())); cbk.Items.Add("D. " + Server.HtmlEncode(sdr["testAns4"].ToString())); cbk.Font.Size = 11; for (int j = 1; j <= 4; j++) { cbk.Items[j - 1].Value = j.ToString(); //cbk.Attributes["onclick"] = " db(1, "+i.ToString()+")"; cbk.Items[j - 1].Attributes.Add("onclick", " db(" + bie.ToString() + ", " + num++ + ")");//给input标签加事件 //cbk.Items[j - 1].Attributes.Add("name", " db" + bie.ToString() + "");//给input标签加事件 } num = 1; bie++; Ans += sdr[6].ToString(); if (Session["a"] == null) { Session["Ans"] = Ans; } Panel1.Controls.Add(littxt); Panel1.Controls.Add(cbk); Panel1.Controls.Add(litti); i++; tNUM++;
HTML code<tr> <td><input id="cbk9_0" type="checkbox" name="cbk9$0" onclick=" db(8, 1);" /><label for="cbk9_0">A. 氮质血症</label></td> </tr><tr> <td><input id="cbk9_1" type="checkbox" name="cbk9$1" onclick=" db(8, 2);" /><label for="cbk9_1">B. 高血糖</label></td> </tr><tr> <td><input id="cbk9_2" type="checkbox" name="cbk9$2" onclick=" db(8, 3);" /><label for="cbk9_2">C. 酮症</label></td> </tr><tr> <td><input id="cbk9_3" type="checkbox" name="cbk9$3" onclick=" db(8, 4);" /><label for="cbk9_3">D. 高血钠</label></td> </tr> </table></div><input type='hidden' name='db_9' id='db_9' value='' answer='1,2,4'/><div class='result' id='result_9' >10、1+2=<table id="cbk10" border="0" style="font-size:11pt;"> <tr> <td><input id="cbk10_0" type="checkbox" name="cbk10$0" onclick=" db(9, 1);" /><label for="cbk10_0">A. 1</label></td> </tr><tr> <td><input id="cbk10_1" type="checkbox" name="cbk10$1" onclick=" db(9, 2);" /><label for="cbk10_1">B. 2</label></td> </tr><tr> <td><input id="cbk10_2" type="checkbox" name="cbk10$2" onclick=" db(9, 3);" /><label for="cbk10_2">C. 3</label></td> </tr><tr> <td><input id="cbk10_3" type="checkbox" name="cbk10$3" onclick=" db(9, 4);" /><label for="cbk10_3">D. 4</label></td> </tr>