simple binding properties on the page - simple but impossible

Discussion in 'ASP .Net' started by Eric, Dec 7, 2006.

  1. Eric

    Eric Guest

    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
    Eric, Dec 7, 2006
    #1
    1. Advertising

  2. Eric

    kbutterly Guest

    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,
    Kathryn
    Eric wrote:
    > 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
    kbutterly, Dec 7, 2006
    #2
    1. Advertising

  3. Eric

    kbutterly Guest

    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


    kbutterly wrote:
    > 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,
    > Kathryn
    > Eric wrote:
    > > 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
    kbutterly, Dec 7, 2006
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Victor Porton
    Replies:
    1
    Views:
    695
    Steven T. Hatton
    Aug 29, 2004
  2. Chrissy
    Replies:
    4
    Views:
    2,337
    Jonathan N. Little
    May 27, 2006
  3. Replies:
    9
    Views:
    530
    CBFalconer
    Apr 25, 2006
  4. HP
    Replies:
    3
    Views:
    623
  5. Replies:
    5
    Views:
    254
    Michele Dondi
    Jun 30, 2006
Loading...

Share This Page