• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 402
  • Last Modified:

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.
  • 3
  • 3
1 Solution
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
SegFaultAuthor Commented:
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
        lblCheckBoxListInfo.Text = msg
    End Sub
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

SegFaultAuthor Commented:
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.

I think checkBoxList behaves exactly like checkbox. I gave you this sample (it is running fine on my pc) to check that everything is alright with yours
SegFaultAuthor Commented:
i'll give it a shot. its probably a configuration thing on my server or something.
Bob LearnedCommented:
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.


EE Cleanup Volunteer

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now