How to make div/panel visible on basis of radiobuttonlist selection ?


If we have to do this task on client side without using postback then we can do using Javascript like this

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ""&gt;

<html xmlns=""&gt;
<head runat="server">

<script type="text/javascript">

function HidDiv()
document.getElementById(‘Div1’).style.display = "none";
document.getElementById(‘Div2’).style.display = "none";

function showhidesearch()
var radio1=document.getElementById(‘<%=RadioButtonList1.ClientID %>’);

var rblopts = radio1.getElementsByTagName("input");

else if(rblopts[1].checked)




<body onload = "javascript:HidDiv();">
<form id="form1" runat="server">
<div style="margin-left:200px;">

<asp:RadioButtonList ID="RadioButtonList1" runat="server"
RepeatDirection="Horizontal" style="font-weight: 700"
onclick="showhidesearch()" >
<asp:ListItem Value="1">First Div</asp:ListItem>
<asp:ListItem Value="2">Second Div</asp:ListItem>
<br />

<div id="Div1" style="background-color:Blue; width:200px; height:200px;" runat="server">
<br />
<b> This is the first div </b>

<br />
<br />

<div id="Div2" style="background-color:Lime; width:200px; height:200px;" runat="server">
<br />
<b> This is the Second div</b>




3 Responses to “How to make div/panel visible on basis of radiobuttonlist selection ?”

  1. Jon Says:

    Excellent post. I certainly appreciate this site.
    Continue the good work!

    • Chandra Dev Says:

      Thanks. I will do it.

  2. velvahoffman Says:

    I’m amazed, I must say. Rarely do I encounter a blog that’s both equally educative
    and interesting, and let me tell you, you have hit
    the nail on the head. The problem is something which too few people are speaking intelligently about.

    I am very happy that I found this during my hunt
    for something relating to this.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: