11

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

user259119
  • 131
  • 1
  • 1
  • 4

11 Answers11

20

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

robert
  • 1,523
  • 5
  • 19
  • 27
  • 1
    I have the exact same issue as OP described, and I have my dropdownlist with ClientIDMode="Static" too. Removing ClientIDMode just solved it! I wouldn't have found it if you didn't mention about this! – Kagawa Jan 09 '13 at 06:43
  • 1
    Changing to **inherit** might not be enough. If the application default or parents are with ClientMode **static**, **inherit** will not solve the problem. It must be set to **AutoID** or **Predictable** to garantee that will generate the correct clientID – Nuno Agapito Apr 01 '14 at 10:42
  • This was my problem too! Oh man THAT is not obvious. Thank you! – n8wrl Mar 09 '16 at 16:51
  • Alternatively you can add manual AsyncPostBackTriggers for these dropdowns with ClientIDMode="Static". – Sebazzz Dec 08 '21 at 10:19
5

Me having the same problem...

CHECK your WEB.CONFIG

<xhtmlConformance mode="Legacy"/>

for this line.. and JUST REMOVE IT!!

Worked for me. Thanks http://andrew-murphy.co.uk/?p=152

Sin
  • 1,836
  • 2
  • 17
  • 24
5

You have your drop down list with an AutoPostBack set to true. That's why you have it post back instead of AsyncPostBack, if that is what you wanted.

Remove the AutoPostBack=true from the dropdownlist and set an Async trigger for your UpdatePanel set to the dropdownlist and its eventname="SelectedIndexChanged"

Musakkhir Sayyed
  • 7,012
  • 13
  • 42
  • 65
HomerJones
  • 51
  • 1
  • 2
2

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

JCallico
  • 1,446
  • 18
  • 25
2

If you have some asp component with Autopostback="true" and ClientIdMode="Static", you have to use the trigger.

Like this:

<asp:UpdatePanel ID="upPrinceOffuce" runat="server">
    <Triggers>
        <asp:AsyncPostBackTrigger ControlID="ddlPrintOffice" EventName="SelectedIndexChanged" />
    </Triggers>
    <ContentTemplate>
         <asp:DropDownList ID="ddlPrintOffice" runat="server" ClientIDMode="Static" AutoPostBack="true" ...blah blah
</asp:DropDownList>
    </ContentTemplate>
</asp:UpdatePanel>
Louis van Tonder
  • 3,664
  • 3
  • 31
  • 62
mRizvandi
  • 983
  • 1
  • 8
  • 20
  • When I use trigger, it can't find the DropDownList... http://stackoverflow.com/questions/30352866/how-to-prevent-full-page-postback-on-selectedindexchange-for-dropdownlist – SearchForKnowledge May 20 '15 at 15:28
2

Excuse my lack of programing skills :| It all worked all the time, but because one of the actions page "looked" like it's POST BACKED, when it wasn't. What a shame!!!

Sorry for waisting Your time!

user259119
  • 131
  • 1
  • 1
  • 4
  • 2
    you can determine if the page did full postback or partial postback here: http://stackoverflow.com/questions/15893011/determine-if-and-which-partial-postback-occurred-in-pageload-with-javascript-i – Chani Poz Jan 07 '14 at 21:52
1

How do you bind your DropDown? The code that you have provided works on my side with static items. Perhaps it is something in the other controls that is causing the problem.

I have noticed that your UpdatePanel has its UpdateMode property set to conditional, however you haven't defined any triggers.You can try to explicitly set that the update panel should perform async postback when your dropdown triggers its selectedIndexChanged event. You can use something like the following markup:

<asp:UpdatePanel ID="upMain" runat="server" UpdateMode="Conditional" Visible="true"
    RenderMode="Inline">
    <ContentTemplate>
        <asp:DropDownList ID="ddlNewService_PortTelco" runat="server" Width="250" 
            AutoPostBack="true" OnSelectedIndexChanged="Provision_PortedTelcoChanged">
        </asp:DropDownList>
    </ContentTemplate>
    <Triggers>
        <asp:AsyncPostBackTrigger ControlID="ddlNewService_PortTelco" EventName="SelectedIndexChanged" />
    </Triggers>
</asp:UpdatePanel>
Genady Sergeev
  • 1,650
  • 9
  • 11
  • Hi! Thanks for a reply. I tried adding AsyncPostBack trigger as well, but it didn't help. It's not in my example, as for what I know if an OBJECT causing an Update is INSIDE Update Panel then You don't need to specify the Trigger. Triggers are required for Objects OUTSIDE the UpdatePanel. I tried changing UpdateMode to Always, but that didn't help as well. I'm already playing with the code, and I noticed that when I created OTHER UpdatePanel just after this one, and I added identical code inside it worked well :/ So there must be something inside this UpdatePanel which makes it work wrong. – user259119 Jan 26 '10 at 10:07
1

Set AutoID value to ClientIDMode property. It worked for me. I have had different behaviour in different browsers (i.e. Google chrome and Firefox).

Olsi
  • 11
  • 2
  • It is a solution, If you meet this problem when you use bootstrap select (dropdownlist) in an updatepanel. – Leo Apr 09 '20 at 19:16
0

Had the same problem when the Dropdownlist Autopostback attribute was set to true and fixed the problem by adding the dropdownlist ID to the updatepanel trigger

0

I had this problem. My Dropdownlist was inside of an HTML table and I had my Update Panel wrapped around two individual rows. I fixed the problem by wrapping the Update Panel around the entire table rather than just the two rows.

myQwil
  • 442
  • 3
  • 11
0

One alternative to fix this issue is:

Declare the library

using AjaxControlToolkit;

Then you can do something on these lines

private void InitControl()
{        
            //FIX - DROP DOWN
            ToolkitScriptManager scrManager = (ToolkitScriptManager)Page.Master.Controls[0].Controls[0].FindControl("manScript");
            scrManager.RegisterAsyncPostBackControl(ddlNewService_PortTelco);
}
Scriptworks
  • 495
  • 1
  • 6
  • 10