RadioButton rb; Label lb;如何将编程创建的标签的文本分配给html正文中的其他标签?
while (reader.Read())
{
rb = new RadioButton(); **//radio buttuns created**
lb = new Label(); **// labels created**
lb.Text = reader[0].ToString(); *// each label's text assigned*
rb.Attributes.Add("OnClick", "getSelectedAuthor('"+lb.Text.ToString()+"')");
PlaceHolder1.Controls.Add(rb); *//when the radio clicked,function called*
PlaceHolder1.Controls.Add(lb); *// to set use the text of label*
PlaceHolder1.Controls.Add(new LiteralControl("<br />"));
}
conAuthorTbl.Close();
// innerthtml不为宗旨的工作,// becuse我需要// Labe2的文本发送到其他页面,//当我使用Response.Redirect(..),//有没有字符串来//从Label2的
<script language="javascript" type="text/javascript">
function getSelectedAuthor(text) {
document.getElementById("Label2").innerText = text;
}
</script>
//这里我想设置文本
<div>
<asp:Label ID="Label2" runat="server" Text="" ></asp:Label>
</div>
你的问题离开很多想象力。如果您使用的是Response.Redirect,那么您可以将RadioButton的值附加到QueryString以在重定向页面上使用。 – aaroncatlin 2012-03-06 12:59:02
您必须从服务器端而不是客户端设置标签文本属性。 – arunes 2012-03-06 13:00:02
我正确使用了Response.Reditect,但它不起作用。问题是没有任何字符串属于Label2 – user1214973 2012-03-06 13:03:05