CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Aug 2000
    Location
    Essex, Uk
    Posts
    1,214

    updating a form after Ajax

    Hi all,

    I have an Ajax popup control on a form

    When the form loads, I populate a standard combo box. There is an option for the users to add more entries into the Database. When the user selects this option I present them with my ajax modal popup control. The user uses the modal popup to add entries into the DB. This all works fine. The problem is that at the end of the update, I call a sub that repopulates my dropdown which is on the main form. It seems to go through the motions, but when I select the dropdown I cannot see my new entry in the list. If I kill the page and start again, then my new entry appears.

    So, how can I cause my dropdown to update after I have used the Ajax control?
    If you find my answers helpful, dont forget to rate me

  2. #2
    Join Date
    May 2002
    Posts
    10,943

    Re: updating a form after Ajax

    Sounds like you aren't coding this by hand. What are you using?
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

  3. #3
    Join Date
    Aug 2000
    Location
    Essex, Uk
    Posts
    1,214

    Re: updating a form after Ajax

    Hi,

    I am coding by hand. Basically I need to force a postback when my popup closes, but I dont know how.

    in the aspx page I have the following declared:

    Code:
    <asp:Content ID="Content1" ContentPlaceHolderID="content" Runat="Server">
    <cc1:ModalPopupExtender ID="mpeSubmitScopeGroup" runat="server" PopupControlID="SubmitScopeGroupPanel" TargetControlID="btnFake" BackgroundCssClass="modalBackground" CancelControlID="ScopeGroupCancelButton" >
    </cc1:ModalPopupExtender>
    
    
    <script type="text/javascript">
    	
    	function showScopeGroupPopup()
    	{
    		$get('<%=SubmitScopeGroupPanel.ClientID %>').className = "modalpopup";
    		$find('<%=mpeSubmitScopeGroup.ClientID %>').show();
    		return false;
    	}
    	
    </script>
    at the top then later I have:


    Code:
          <asp:Panel ID="SubmitScopeGroupPanel" runat="server" Height="250px" Width="550px" BackColor="White" BorderStyle="Solid" CssClass="hidden">
    	    <ajax:UpdatePanel ID="UpdatePanel1" runat="server">
    		    <ContentTemplate>
    		        <table border="1" style="width: 100%">
    ........
    ........
                    <asp:Button ID="ScopeGroupSave" runat="server" Text="Save" ValidationGroup="valgroup" />&nbsp;
    			    <asp:Button ID="ScopeGroupCancelButton" runat="server" Text="Cancel" CausesValidation="False" />
    		    </ContentTemplate>
    		</ajax:UpdatePanel>
    then in my code behind on my button_click event I do what I need to do and then use

    Code:
                mpeSubmitScopeGroup.Hide()
    to close the popup. It's at this point I want my dropdown to re-load.
    If you find my answers helpful, dont forget to rate me

  4. #4
    Join Date
    May 2002
    Posts
    10,943

    Re: updating a form after Ajax

    You could use window.opener to reference the parent window. Then access the drop-down and repopulate it.
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

  5. #5
    Join Date
    Aug 2000
    Location
    Essex, Uk
    Posts
    1,214

    Re: updating a form after Ajax

    I dont suppose you could point me towards an example?
    If you find my answers helpful, dont forget to rate me

  6. #6
    Join Date
    May 2002
    Posts
    10,943

    Re: updating a form after Ajax

    In the popup window...

    Code:
    <script type="text/javascript">
    function repopulatebox(){
      // grab the combo
      var theCombo = window.opener.document.getElementById('ID of <select>');
      // truncate the combo
      theCombo.length = 0;
      // now repopulate the list. you can use ASP.NET to write this JS part.
      .....
    }
    </script>
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured