Ok, this is a total hack, but I'm assuming want to desperately avoid a
postback. You can use script to check if the checkbox is checked, get at the
innertext of the Label with some Javascript and stuff it into the textbox.
Here's a sample that might get you started:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>chbxfr m</title>
<meta name="GENERATOR " content="Micros oft Visual Studio .NET 7.1">
<meta name="CODE_LANG UAGE" content="Visual Basic .NET 7.1">
<meta name="vs_defaul tClientScript" content="JavaSc ript">
<meta name="vs_target Schema"
content="http://schemas.microso ft.com/intellisense/ie5">
<script language=javasc ript>
function elemnts() {
for(i = 0; i < document.all.le ngth; i++){
if (document.all(" chkRed").checke d==true) {
if (document.all(i ).tagName=="LAB EL") {
document.all("T extBox1").value =document.all(i ).innerText
break;
}
}
}
}
</script>
</HEAD>
<body MS_POSITIONING= "FlowLayout ">
<form id="Form1" method="post" runat="server">
<P>
<asp:CheckBox id="chkRed" runat="server"
Text="Red"></asp:CheckBox>&n bsp;</P>
<P>
<asp:TextBox id="TextBox1" runat="server"> </asp:TextBox></P>
<P>
<asp:Button id="Button1" runat="server" Text="OK" ></asp:Button></P>
</form>
</body>
</HTML>
Private Sub Page_Load _
(ByVal sender As System.Object, _
ByVal e As System.EventArg s) _
Handles MyBase.Load
Button1.Attribu tes.Add("onclic k", "elemnts(); ")
End Sub
Ken
MVP [ASP.NET]
Toronto
"Kb" <kb**@canada.co m> wrote in message
news:ur******** ******@TK2MSFTN GP09.phx.gbl...
Hi all,
I have an asp:checkbox on a form, and i added onclick attribute to it.
When
the checkbox is clicked I want to add its text to a textbox. But I can't
get
its text. The checkbox is rendered in html separately, followed by the
<label for> tag - that's where the text is. But how to access it?
Any help is appreciated.