my question is very simple, I have a RadioButtonList which has all Items disabled in the markup. In Page_Load, I am enabling all of them programmatically and doing rdo.Items[0].Selected = true;, when chooses any other option, it does not do postbacks.
When I take off the Items[0].Selected = true part, it works fine.
And yes, I cannot select Items[0] in markup because the stuff has to go through conditions.
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
test.Items(0).Enabled = True
test.Items(1).Enabled = True
test.Items(1).Selected = True
End If
End Sub
Microsoft stuff always acts up on me when I have deadlines unfortunately....
I will put in some jQuery code to do postbacks while I wait for what you guys have for solution to this.
fahadash
Member
73 Points
80 Posts
AutoPostBack=true does not work when I select a particular Item in Page_Load
Apr 11, 2012 01:48 PM|LINK
Hi,
my question is very simple, I have a RadioButtonList which has all Items disabled in the markup. In Page_Load, I am enabling all of them programmatically and doing rdo.Items[0].Selected = true;, when chooses any other option, it does not do postbacks.
When I take off the Items[0].Selected = true part, it works fine.
And yes, I cannot select Items[0] in markup because the stuff has to go through conditions.
tdmca
Contributor
2396 Points
661 Posts
Re: AutoPostBack=true does not work when I select a particular Item in Page_Load
Apr 11, 2012 01:52 PM|LINK
if code of Page_Load
Items[0].Selected = true
is inside
if(!IsPostBack)
{
}
fahadash
Member
73 Points
80 Posts
Re: AutoPostBack=true does not work when I select a particular Item in Page_Load
Apr 11, 2012 01:56 PM|LINK
It is inside if (!IsPostBack) { }
I do not see it posting back, when I click on radio buttons; I do not see any javascript run and refresh the page.
tdmca
Contributor
2396 Points
661 Posts
Re: AutoPostBack=true does not work when I select a particular Item in Page_Load
Apr 11, 2012 02:02 PM|LINK
if you have masterpage set its enableviewstate to true
fahadash
Member
73 Points
80 Posts
Re: AutoPostBack=true does not work when I select a particular Item in Page_Load
Apr 11, 2012 02:13 PM|LINK
Here is a simple example with no masterpage, and acting crazy...
<asp:RadioButtonList ID="test" runat="server" RepeatDirection="Horizontal" AutoPostBack="True" > <asp:ListItem Selected="True" Text="Test1" Value="1" Enabled="False"></asp:ListItem> <asp:ListItem Selected="False" Text="Test2" Value="2" Enabled="False"></asp:ListItem> </asp:RadioButtonList>Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If Not IsPostBack Then test.Items(0).Enabled = True test.Items(1).Enabled = True test.Items(1).Selected = True End If End SubMicrosoft stuff always acts up on me when I have deadlines unfortunately....
I will put in some jQuery code to do postbacks while I wait for what you guys have for solution to this.
fahadash
Member
73 Points
80 Posts
Re: AutoPostBack=true does not work when I select a particular Item in Page_Load
Apr 11, 2012 02:22 PM|LINK
I thought so....
Here is the workaround, use jQuery code for post back
<script type="text/javascript"> $(document).ready(function () { $("input[type=\"radio\"][name*=\"test\"]").change(function () { __doPostBack($(this).attr("name"), ''); }); }); </script>MS has the issue report now.
https://connect.microsoft.com/VisualStudio/feedback/details/736371/autopostback-true-does-not-work-when-i-select-a-particular-item-in-page-load