simple binding properties on the page - simple but impossible

E

Eric

Simple problem - binding Visible property of label to Checked
property of radiobutton on the same form.
How do I do that in VS2005??
Visible="<%# radiob.Checked %>" - DOESN'T WORK
It was so simple in 2003 but how it can be done in VS05
using binding expressions. Theres no controls listing under 'Expressions'
on the designer properties window.
Please help.

Eric
 
K

kbutterly

Eric,

How about something like this:

in your Page.aspx:
<head runat="server">
<title>Untitled Page</title>
<script language=javascript>
function toggleLabel() {
with (document) {
if (getElementById('CheckBox1').checked) {
getElementById('Label1').style.visibility='visible';
}else{
getElementById('Label1').style.visibility='hidden';
}
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:CheckBox ID="CheckBox1" runat="server" onClick="toggleLabel()" />
<asp:Label ID="Label1" runat="server" Text="Label">test</asp:Label>
</div>
</form>
</body>


Does that do what you want?

Regards,
 
K

kbutterly

Eric,


Or alternatively, in page1.aspx:
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:CheckBox ID="CheckBox1" runat="server" autopostback=true/>
<asp:Label ID="Label1" runat="server" Text="Label">test</asp:Label>
</div>
</form>
</body>

note the autopostpack=true on the checkbox

and then in the code page, page1.aspx.vb

Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load

If Page.IsPostBack Then
If CheckBox1.Checked Then
Label1.Visible = True
Else
Label1.Visible = False
End If
End If

Good luck,
kathryn
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,898
Latest member
BlairH7607

Latest Threads

Top