0

i'm kinda new in web programming,
i'm trying to design a search page. i want to creating few radio buttons where each click on a radio button will show a div contains the related search div's. and from there to do the query to the database(not related to the post)

how can i do that ? tried to search for it , and didn't get good answer. i want that the change of the page will be in server side and not the client side. p.s. i have been working with ajax control kit so far..

thanks for the help.

RonenIL
  • 273
  • 3
  • 8
  • 17

2 Answers2

0

You just need an UpdatePanel, radio buttons and a MultiView control.

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<div>
<asp:RadioButton ...
<asp:RadioButton ...
</div>
<asp:MultiView ID="mvAll" runat="server" ActiveViewIndex="-1">
<asp:View ID="vwFirst" runat="server">
</asp:View>
<asp:View ID="vwSecond" runat="server">
</asp:View>
...
</asp:MultiView>
</ContentTemplate>
</asp:UpdatePanel>

When the selected radio button changed you just set the View related to be active,

mvAll.SetActiveView(ViewIDYouNeed);
A_Nabelsi
  • 2,524
  • 18
  • 21
  • i tried to do as you said but it didn't work i inserted the "mvall.setactive.." into protected void RadioButton1_CheckedChanged(object sender, EventArgs e) – RonenIL Dec 09 '10 at 16:45
  • Did you set the AutoPostBack property of the radio buttons to true? – A_Nabelsi Dec 09 '10 at 16:48
0

You can accomplish this with Panels and an Update Panel.

<asp:RadioButton ID="rdo1" AutoPostBack="true" GroupName="radios" runat="server" OnCheckedChanged="ShowDivs" />
<asp:RadioButton ID="rdo2" AutoPostBack="true" GroupName="radio2" runat="server" OnCheckedChanged="ShowDivs" />

<asp:UpdatePanel runat="server" UpdateMode="Conditional">
<ContentTemplate>
    <asp:Panel ID="pnl1" runat="server" Visible="false"></asp:Panel>
    <asp:Panel ID="pnl2" runat="server" Visible="false"></asp:Panel>
</ContentTemplate>
<Triggers>
    <asp:AsyncPostBackTrigger ControlID="rdo1" />
    <asp:AsyncPostBackTrigger ControlID="rdo2" />
</Triggers>
</asp:UpdatePanel>

You would then handle setting the Visible property of the panels in your ShowDivs method in your code behind.

Or, you could use jquery/javascript to accomplish this.

<input type="radio" onClick="ShowDiv(1)" />

function ShowDiv(id) {
 HideDivs();
 $(id).show('slow');
}
Jack Marchetti
  • 15,536
  • 14
  • 81
  • 117
  • Well youl would check which radiobutton was "checked" and based off that set the visible property to True for the panel you want to show. – Jack Marchetti Dec 09 '10 at 17:27