Link to home
Start Free TrialLog in
Avatar of SegFault
SegFault

asked on

C#, ASP.Net -- Autopostback not autoposting back

Hi all.

I have a web form using aspnet controls. It works fine for my submit button. I have 3 check box controls which i have set to autopostback, however, then I check and un-check them, it does nothing.  I'm still pretty new at this stuff, so I might be missing something obvious. I have checked my main page and don't see anything preventing it.  When I looka the rendered HTML, I don't see anything in the HTML that would cause the Checkbox to post back to the server.

Anybody got any ideas? Its a real straight forward form.

Here is sample of the HTML code in the VS.Net(pre-rendered)
      <asp:checkbox id="chkBoxDelete" style="Z-INDEX: 102; LEFT: 296px; POSITION: absolute; TOP: 18px" runat="server" width="173px" height="25" text="Delete Group(s)" tabindex="3" autopostback="True"></asp:checkbox>

Here is the Rendered HTML

      <span style="height:25px;width:173px;Z-INDEX: 102; LEFT: 296px; POSITION: absolute; TOP: 18px"><input id="chkBoxDelete" type="checkbox" name="chkBoxDelete" /><label for="chkBoxDelete">Delete Group(s)</label></span>


thanks in advance.
Avatar of iboutchkine
iboutchkine

If you set AutoPostBAck to true it must refrech the state of checkbox. The only thing that I can see might happen is that you init control in the Page_load eevnt where you have something like

If Page.IsPostBack then...
after that you are init the check box

It might cause that Autopostback will not fire.

Try to change the place wher you bind controls
Avatar of SegFault

ASKER

I think I understand what you are saying. The problem is, that the page is not even posting if you click the check box. So it never makes it back to the server to re-init or re-fetch the state of the checkbox.

I would have thought that the .Net Web Controls would have added some JScript or something to cause the form to submit itself in the click event of the check box. However, I don't see anything.

Do I have a misconception on how the Autopostback stuff works?

Add CheckBoxList, set the AutoPostback property to true and try the following code

 Private Sub cblContinents_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cblContinents.SelectedIndexChanged
        Dim li As ListItem, msg As String
        ' check the Selected property of each item
        For Each li In cblContinents.Items
            If li.Selected Then
                msg &= String.Format("Item = {0}, Value = {1}<br>", li.Text, li.Value)
            End If
        Next
        lblCheckBoxListInfo.Text = msg
    End Sub
I'm not using a checkBoxList, I'm just using a regular checkbox.

The way its working on my setup though, even this won't work. I already have the events defined and wired up. But the HTML page is never posting back(ie calling form submit) when you click the check box.

very strange. I'll do some poking around with some of the other controls. see what they do.

thanks
ASKER CERTIFIED SOLUTION
Avatar of iboutchkine
iboutchkine

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
i'll give it a shot. its probably a configuration thing on my server or something.
Avatar of Bob Learned
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

Answered by iboutchkine

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

TheLearnedOne
EE Cleanup Volunteer