Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Drop Down List (in Update Panel) causing FULL PostBack!

I have a problem with my AJAX and ASP.NET 3.5 :( Problem is really weird, as I'm using the same thing on different page and it works fine in there, but on this specific page, this is not working.

Here's what I have:

    <asp:UpdatePanel ID="upMain" runat="server" UpdateMode="Conditional" Visible="true" RenderMode="Inline">
                <ContentTemplate>
<asp:DropDownList ID="ddlNewService_PortTelco" runat="server" Width="250" CssClass="dropdown" AutoPostBack="true" OnSelectedIndexChanged="Provision_PortedTelcoChanged"></asp:DropDownList>
</ContentTemplate>
</asp:UpdatePanel>

On the way before the DropDown there is one DIV (html one), and then few asp:Panels. I do not understand why this is causing a FULL POST BACK ?!

Any ideas ? Thanks

like image 980
user259119 Avatar asked Jan 26 '10 09:01

user259119


2 Answers

i had the same problem... altho it's not showing in the copied code here, check to make sure you don't have any controls with ClientIDMode=Static within the updatepanel .... make them inherit

at least any controls that may trigger a postback

like image 133
robert Avatar answered Sep 16 '22 16:09

robert


Setting the AutoPostBack attribute to true should be enough to cause a partial postback but it's not what happens and a full postback is triggered instead as you correctly described.

The following workaround works for me:

  1. Drop the AutoPostBack attribute.
  2. Trigger the postback using the "onchange" client side event.

This is how the original DropDownList should look like:

<asp:DropDownList ID="ddlNewService_PortTelco" runat="server" Width="250" CssClass="dropdown" OnChange="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(this.name, '', true, '', '', false, true))" OnSelectedIndexChanged="Provision_PortedTelcoChanged"></asp:DropDownList>

For more details regarding the WebForm_PostBackOptions parameters see below:

function WebForm_PostBackOptions(eventTarget, eventArgument, validation, validationGroup, actionUrl, trackFocus, clientSubmit)

http://msdn.microsoft.com/en-us/library/system.web.ui.postbackoptions_members(v=VS.90).aspx

like image 36
JCallico Avatar answered Sep 20 '22 16:09

JCallico