I have 2 issues with my code below.
1) I am not able to get the rbtnRequestType_OnSelected
IndexChang
e method below in my user control to fire when I change selected values in the radiobuttonlist at runtime. Do I need force a postback or something in my OnSelectedIndexChange event or something?
Note: however, if I have some other control on the page such as a button adn click that, it forces a postback and the method then fires off fine but I don't know why it does not invoke that method when kust changing values in the radiobuttonlist to begin with.
2) When I do get the rbtnRequestType1_OnSelecte
dIndexChan
ge1 method to fire, it runs RequestType.cpeRequestType
1.Collapse
d = true; but then goes back to running rbtnRequestType_OnSelected
IndexChang
e again and I'm not sure. But at runtime, I am not seeing that panel collapsing so not sure why.
Here is what I've tried so far:
----------------------
MyPage.aspx.cs:
----------------------
public partial class RequestPage : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
RequestType.rbtnRequestTyp
e_OnSelect
edIndexCha
nge1 += new EventHandler(rbtnRequestTy
pe1_OnSele
ctedIndexC
hange1);
...
private void rbtnRequestType1_OnSelecte
dIndexChan
ge1(object
sender, EventArgs e)
{
if (RequestType.rbtnRequestTy
pe1.Select
edIndexCha
nged == 0)
{
RequestType.cpeRequestType
1.Collapse
d = true;
}
}
----------------------
MyControl.ascx:
----------------------
<td>
<asp:RadioButtonList ID="rbtnRequestType" OnSelectedIndexChanged="rb
tnRequestT
ype_OnSele
ctedIndexC
hange" runat="server" >
<asp:ListItem Text="New User" Value="NewUser" Selected="true" />
<asp:ListItem Text="Existing User" Value="ExistingUser" Selected="false" />
<asp:ListItem Text="Multiple Users" Value="MultiUser" Selected="false" />
<asp:ListItem Text="New System Account" Selected="false" />
<asp:ListItem Text="Existing System Account" Selected="false" />
<asp:ListItem Text="Multiple System Accounts" Selected="false" />
</asp:RadioButtonList>
</td>
--------------------------
MyControl.ascx.cs:
--------------------------
#region public events
public event EventHandler rbtnRequestType_OnSelected
IndexChang
e1;
private void rbtnRequestType_OnSelected
IndexChang
e(object sender, EventArgs e)
{
if (rbtnRequestType_OnSelecte
dIndexChan
ge1 != null)
{
rbtnRequestType_OnSelected
IndexChang
e1(this, e);
}
}
#endregion
Start Free Trial