{
SqlDataReader reader = cmdAuthors.ExecuteReader();
RadioButton rb;
Label lb;
while(reader.Read()){
rb=new RadioButton();
lb=new Label();
lb.Text=reader[0].ToString();
rb.Attributes.Add("OnClick","getSelectedAuthor('"+lb.Text.ToString()+"')");
PlaceHolder1.Controls.Add(rb);
PlaceHolder1.Controls.Add(lb);
PlaceHolder1.Controls.Add(new LiteralControl("<br />"));
}
}
//我不知道在这个函数中要写什么才能使Label2.text = Text; // document.getElementById(“Label2”)。value = text不起作用
function getSelectedAuthor(text){
}
<div>
<asp:Label ID="Label2" runat="server" Text="" ></asp:Label>
</div>
答案 0 :(得分:15)
使用innerHTML而不是value设置值,例如
document.getElementById("Label2").innerHTML = 'text';