I have tried multiple ways to get the button to show up but nothing is working.
This is what I have in the c# code:
protected void rblistcourses_OnSelectedIndexChanged(object sender, EventArgs e)
{
btnremoveselectedcourse.Visible = true;
}
And this is the HTMl aspx portion
<asp:Button ID="btnremoveselectedcourse" runat="server"
OnClick="btnremoveselectedcourse_Click" Text="Remove selected"
OnSelectedIndexChanged="rblistcourses_OnSelectedIndexChanged"
AutoPostBack="true" ViewStateMode="Enabled" />
2
Answers
I am not familiar with asp.net, but looking at your code it looks like the
rblistcourses_OnSelectedIndexChanged
event should be assigned to yourRadioButton
orRadioButtonList
, not to yourbtnremoveselectedcourse
.The
btnremoveselectedcourse
will be the changed by therblistcourses_OnSelectedIndexChanged
event, but another component must call it, or it will never happen.This is a good question that could well be served by using client-side code (JavaScript).
However, for now, given that server-side code was posted, then the following server-side code will work:
And the result is this:
And the markup: