By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,948 Members | 1,559 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,948 IT Pros & Developers. It's quick & easy.

Ajax loaded div with autopostback

P: 1
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 ------
Expand|Select|Wrap|Line Numbers
  1.  <script> 
  2. protected void ddlPrices_SelectedIndexChanged(object sender, EventArgs e)
  3.    {
  4.     lblPrice.Text = ddlPrices.SelectedValue.ToString();
  5.    }
  6.  </script>
  7.  
  8.  
  9. <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
  10.      <asp:UpdatePanel ID="UpdatePanel1" runat="server">
  11.     <ContentTemplate>
  12. <asp:DropDownList ID="ddlPrices" runat="server" AutoPostBack="true" 
  13.     onselectedindexchanged="ddlPrices_SelectedIndexChanged">
  14. <asp:ListItem>Basic</asp:ListItem>
  15. <asp:ListItem>Pro</asp:ListItem>
  16. <asp:ListItem>Platinum</asp:ListItem>
  17. <asp:ListItem>Baller!</asp:ListItem>
  18. </asp:DropDownList> 
  19.  
  20. <asp:Label ID="lblPrice" runat="server"></asp:Label>          
  21. </ContentTemplate>
  22. </asp:UpdatePanel>
  23.  
---- default.aspx ------
Expand|Select|Wrap|Line Numbers
  1. <script>
  2. $(document).ready(function () {
  3. $("li#empNav1").click(function () {
  4. $("div.subItem").load('external.aspx');
  5. });
  6. });
  7. </script>
  8.  
  9.  <ul class="nav-left">
  10. <li id="empNav1" class="selected"><a href="#">Employer Overview</a></li>
  11. <li id="empNav2"><a href="#">Why We're Better</a><span></span></li>
  12. </ul>
  13. <div class="subItem"></div>
  14.  
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....
Oct 3 '11 #1
Share this Question
Share on Google+
1 Reply


acoder
Expert Mod 15k+
P: 16,027
This will probably be because the response is cached. Use appropriate headers or make a unique URL using, e.g. date/time stamp:
Expand|Select|Wrap|Line Numbers
  1. (new Date()).getTime()
Oct 13 '11 #2

Post your reply

Sign in to post your reply or Sign up for a free account.