Help: Events not executing

Discussion in 'ASP .Net' started by Guest, Apr 12, 2006.

  1. Guest

    Guest Guest

    Hi Everyone,
    I'm having a problem trying to get the program to execute the
    SelectedIndexChanged event for a Dropdownlist (Combobox). I double clicked
    the control to get the event in the Code-Behind file. I have the following
    declare :
    Protected Sub cmbPORequests_SelectedIndexChanged(ByVal sender As Object,
    ByVal e As System.EventArgs) Handles cmbPORequests.SelectedIndexChanged
    if cmbPORequests.SelectedValue > 0 then
    BindGrid(cmbPORequests.SelectedValue )
    end if
    End Sub

    When I select a new item in the control, the event is not executed. I even
    tried to add the following to the markup:
    <asp:DropDownList ID="cmbPORequests" runat="server" DataTextField=""
    OnSelectedIndexChanged="cmbPORequests_SelectedIndexChanged"
    DataValueField="" Style="left: 298px; top: 109px" Width="175px">
    </asp:DropDownList>
    This didn't work either. One question I did have was: Do I need to set the
    AutoPostBack property to true? From my reading I get the feeling I don't need
    to, but wanted to make sure. Any comments would help. Thanks.
    Michael
     
    Guest, Apr 12, 2006
    #1
    1. Advertisements

  2. Guest

    Guest Guest

    Hi Everyone,
    I've done some testing and have found that if I have AutoPostBack set to
    true, I get the event, BUT ONLY AFTER I click a command button. It seems that
    it has put the events in a queue. If I turn off AutoPostback, the event for
    the combo is never executed. I need the form to respond right away to the
    SelectedIndexChanged event so that it can load the correct data in a grid.
    Thanks for any advice.
    Michael
     
    Guest, Apr 12, 2006
    #2
    1. Advertisements

  3. Guest

    Brock Allen Guest

    AutoPostBack works if javascript is working in the page. If not, then the
    form has to wait until the user has hit the submit button.
     
    Brock Allen, Apr 12, 2006
    #3
  4. Guest

    Guest Guest

    Hi Brock,
    Thanks for the reply. I'm not sure if I got all the setting right, but I
    went into the Intoernet options > Security
    I enabled "Allow scripting of Internet Explorer Webbrowser controls"
    Already enabled "Scripting of Java applets"
    Java permissions = High safty (Does this one need to be changed)

    I made sure of the above settings and ran the project, and it didn't work
    again, at least not when the I select an item from the dropdownlist. Only
    after clicking on one of commad buttons. What do you think. Thanks again so
    much for the reply.
    Michael
     
    Guest, Apr 12, 2006
    #4
  5. Guest

    Jeff Dillon Guest

    What happens if you create a new blank page, drop a server dropdownlist on
    it, double-click on it to get to the code behind, and put in some code for
    the selectedindexchanged event. Does this work?
     
    Jeff Dillon, Apr 12, 2006
    #5
  6. Guest

    Guest Guest

    Hi Jeff,
    I created a new project, added a master page and a content page and on the
    content page I added a dropdownlist. For the SelectedIndexChanged event I
    just added a msgbox call. It works with the AutoPostback set to true. What
    does this you. Is there something in the web.config file that may need to be
    changed? Thanks again for the help.
    Michael
     
    Guest, Apr 12, 2006
    #6
  7. Guest

    Guest Guest

    By the way, I'm using Visual Studio 2005 if that makes a difference.
    Michael
     
    Guest, Apr 12, 2006
    #7
  8. Guest

    Guest Guest

    Thanks for the help. I have it working now. Installing java may have
    corrected something. Its working great now. Thanks for all that helped.
    Michael
     
    Guest, Apr 12, 2006
    #8
  9. Guest

    Jeff Dillon Guest

    I'm confused. Is it working, or not?

    When I do this, I don't have to set anything..it just works. And keep in
    mind you can't call MsgBox, it runs on the server!

    Jeff
     
    Jeff Dillon, Apr 12, 2006
    #9
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.