Link to home
Start Free TrialLog in
Avatar of devvy
devvy

asked on

ASP.NET 1.1 RadioButtonList SelectedIndexChanged event not firing until RB in second RB List is clicked

I'm having a very strange problem with my ASP.NET 1.1 web app. I have two radio button lists, each have AutoPostBack="True", and each have event handlers attached to them. When each respective handler is called, I show/hide a panel of additional fields. The two radio button lists and the panels containing the additional fields are totally unrelated. When I click a radiobutton in either list, it looks like it's posting back, but then the newly selected value is not retained and the event handler is not triggered. When I then click a radio button in the second radio button list, the post back occurs and the event handlers are then triggered correctly upon subsequent clicks. It's very strange.

Thanks for your help!
First Radio Button List (Radio buttons added dynamically upon first page load - No - they're not reloaded upon postbacks as I check for this).
 
<asp:radiobuttonlist id="UnitClassRadioButtonList" runat="server" cssclass="selectionlist" repeatcolumns="3" AutoPostBack="True"></asp:radiobuttonlist>
 
Second Radio Button List:
 
<asp:radiobuttonlist id="ListingContactTypeRadioButtonList" runat="server" cssclass="selectionlist" repeatcolumns="3" AutoPostBack="True">
	<asp:ListItem Value="Owner" Selected="True">Owner</asp:ListItem>
	<asp:ListItem Value="Agent">Agent</asp:ListItem>
</asp:radiobuttonlist>
 
Handlers:
 
		private void UnitClassRadioButtonList_SelectedIndexChanged(object sender, EventArgs e)
		{
			Response.Write("Called event");
			if(this.UnitClassRadioButtonList.SelectedValue == GatewayWest.Common.BindableObjects.UnitClass.Rental)
			{
				this.SalePricePanel.Visible = false;
				this.RentPanel.Visible = true;
			}
			else
			{
				this.SalePricePanel.Visible = true;
				this.RentPanel.Visible = false;
			}
		}
 
		private void ListingContactTypeRadioButtonList_SelectedIndexChanged(object sender, EventArgs e)
		{
			Response.Write("Called event");
			if(this.ListingContactTypeRadioButtonList.SelectedValue == "Agent")
				this.BrokeragePanel.Visible = true;
			else
				this.BrokeragePanel.Visible = false;
		}

Open in new window

Avatar of MaxOvrdrv2
MaxOvrdrv2

hey,

i'm not sure about C#, BUT, in VBNet, the handlers MUST have the following:

private sub UnitClassRadioButtonList_SelectedIndexChanged(object sender, EventArgs e) HANDLES UnitCallRadioButtonList.SelectedIndexChanged

did you code the handlers yourself or let .Net do it for you??

this is the only reason i could see this happening... it doesn`t know which handler to call...
SOLUTION
Avatar of ITHelper80
ITHelper80

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Try adding.
{
    if (!Page.IsPostback) {
    }
    //perform page load actions
}
Can you post the aspx page there might be a spelling error
it shouldn't matter as the function should be getting called in the end anyway...
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Yeah misread ..

So your saying the callbacks are not called until you have clicked a button in both Radio Button lists? It doesn't matter which order?

Rlist1 - No hadler  Rlist2 - Both handlers
Rlist2 - No Handler Rlist 1 - Both Handlers