Ajax loaded div with autopostback

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Ricky Yoyo
    New Member
    • Oct 2011
    • 1

    Ajax loaded div with autopostback

    I have a page that runs a jquery onclick event. The event loads an an external .aspx file into a div. The page that's being loaded has a drop down list with an autopostback attribute that passes the selected item to a label.

    Everything works fine except that the .aspx file that's being loaded will only post back once. After that no more autopostback. Here's my code

    ----- external.aspx ------
    Code:
     <script> 
    protected void ddlPrices_SelectedIndexChanged(object sender, EventArgs e)
       {
        lblPrice.Text = ddlPrices.SelectedValue.ToString();
       }
     </script>
    
    
    <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
         <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
    <asp:DropDownList ID="ddlPrices" runat="server" AutoPostBack="true" 
        onselectedindexchanged="ddlPrices_SelectedIndexChanged">
    <asp:ListItem>Basic</asp:ListItem>
    <asp:ListItem>Pro</asp:ListItem>
    <asp:ListItem>Platinum</asp:ListItem>
    <asp:ListItem>Baller!</asp:ListItem>
    </asp:DropDownList> 
    
    <asp:Label ID="lblPrice" runat="server"></asp:Label>          
    </ContentTemplate>
    </asp:UpdatePanel>
    ---- default.aspx ------
    Code:
    <script>
    $(document).ready(function () {
    $("li#empNav1").click(function () {
    $("div.subItem").load('external.aspx');
    });
    });
    </script>
    
     <ul class="nav-left">
    <li id="empNav1" class="selected"><a href="#">Employer Overview</a></li>
    <li id="empNav2"><a href="#">Why We're Better</a><span></span></li>
    </ul>
    <div class="subItem"></div>
    As stated the div loads just fine, but external.aspx will only update lblPrice once. Then it no longer auto updates. Any help would be greatly appreciated specifics please....
    Last edited by gits; Oct 5 '11, 01:55 PM. Reason: added [code] tags
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    This will probably be because the response is cached. Use appropriate headers or make a unique URL using, e.g. date/time stamp:
    Code:
    (new Date()).getTime()

    Comment

    Working...