It is a common scenario for ASP.NET applications to show/hide controls as a result of user interaction or some event. You can have the same functionality with AJAX Manager as well but should have something in mind. RadAjaxManager relies on the HTML output of controls to be updated, that's why you need to put the control that should be updated in an always visible container like ASP Panel. Then set in the AJAX Manager the AJAX pairs where the AJAX initiator control should update the ASP Panel.
In the code-behind set the Visible property of the control that should be shown/hidden to true or false accordingly.
Below is a sample scenario where we toggle the visibility of an Image using a Button, CheckBox and RadioButtonList.
| ASPX/ASCX |
Copy Code |
<asp:CheckBox ID="CheckBox1" runat="server" AutoPostBack="True" Checked="True" OnCheckedChanged="CheckBox1_CheckedChanged" Text="Toggle Visibility" /> <asp:RadioButtonList ID="RadioButtonList1" runat="server" AutoPostBack="True" OnSelectedIndexChanged= "RadioButtonList1_SelectedIndexChanged" /> <asp:ListItem Selected="True">Visible</asp:ListItem> <asp:ListItem Value="NotVisible">Not Visible</asp:ListItem> </asp:RadioButtonList> <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Toggle visibility" /> <rad:RadAjaxManager ID="RadAjaxManager1" runat="server""> <AjaxSettings> <rad:AjaxSetting AjaxControlID="CheckBox1"> <UpdatedControls> <rad:AjaxUpdatedControl ControlID="Panel1" /> </UpdatedControls> </rad:AjaxSetting> <rad:AjaxSetting AjaxControlID="RadioButtonList1"> <UpdatedControls> <rad:AjaxUpdatedControl ControlID="Panel1" /> </UpdatedControls> </rad:AjaxSetting> <rad:AjaxSetting AjaxControlID="Button1"> <UpdatedControls> <rad:AjaxUpdatedControl ControlID="Panel1" /> </UpdatedControls> </rad:AjaxSetting> </AjaxSettings> </rad:RadAjaxManager> <asp:Panel ID="Panel1" runat="server" Height="95px" Width="244px"> <asp:Image ID="Image1" runat="server" ImageUrl="http://www.telerik.com/images/Homepage/TelerikLogo.gif" Visible="False" /> </asp:Panel> |
And in the code-behind:
| C# |
Copy Code |
|
protected void CheckBox1_CheckedChanged(object sender, EventArgs e) { Image1.Visible = CheckBox1.Checked; } protected void RadioButtonList1_SelectedIndexChanged(object sender, EventArgs e) { Image1.Visible = RadioButtonList1.SelectedValue.Equals("Visible"); } protected void Button1_Click(object sender, EventArgs e) { Image1.Visible = !Image1.Visible; } |
| VB.NET |
Copy Code |
|
Protected Sub CheckBox1_CheckedChanged(ByVal sender As Object, ByVal e As EventArgs) Image1.Visible = CheckBox1.Checked End Sub Protected Sub RadioButtonList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Image1.Visible = RadioButtonList1.SelectedValue.Equals("Visible") End Sub Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Image1.Visible = Not Image1.Visible End Sub |

Also see this KB article on the matter.