This is a migrated thread and some comments may be shown as answers.

Radio button onselectedIdexChanged -> table.visible=true

1 Answer 87 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Myriam
Top achievements
Rank 1
Myriam asked on 24 Nov 2009, 06:23 PM
Hello
I have a RadioButtonList and a table named "TableDateCalendrierCroisement" in a form. When I select the value "2" (which is "oui") on my RadioButtonList, I want the table be visible, when I select the value "1" (which is "non") then I want my table.visible=false. I do it in code behind but I would like to do it with ajax. Is it possible?
Thanks you!

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 25 Nov 2009, 08:31 AM
Hi Myriam,

You can either place the controls in an AjaxPanel or ajaxify the form using an AjaxManager. Also an another suggestion would be to hide/show the table on client side as shown below.

ASPX:
 
<asp:RadioButtonList ID="RadioButtonList1" runat="server"
    <asp:ListItem Value="1" onclick="SetVisibility(this);">non</asp:ListItem> 
    <asp:ListItem Value="2" onclick="SetVisibility(this);">oui</asp:ListItem> 
</asp:RadioButtonList> 
 
<asp:Table ID="Table1" runat="server" Height="94px" Width="246px"
    <asp:TableRow> 
        <asp:TableCell> 
              text 
        </asp:TableCell> 
    </asp:TableRow> 
</asp:Table> 

JavaScript:
 
  function SetVisibility(rbutton) { 
        if (rbutton.value == "1") { 
            document.getElementById("Table1").style.display = "none"
        } 
        else { 
            document.getElementById("Table1").style.display = "block"
        } 
    } 

-Shinu.
Tags
Ajax
Asked by
Myriam
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or