Ajax loaded div, autopost back on loaded page doesn't work
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 ------
<script>
protected void ddlPrices_SelectedIndexChanged(object sender, EventAr开发者_Python百科gs 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 ------
<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....
Update I've tried putting the ddl and the postback into a control that external.aspx references and that didn't work either.
I would try using Server.Execute
to load the external page into the DIV in the OnSelectedIndexChanged
event. Make sure to add runat="server"
to the DIV though, or change the div to a Panel (which resolves to a DIV)
精彩评论