0

I have two drop down lists where one is inside an update panel and the other is outside.When the Index is changed on ddlFaculty the whole page is posted back instead of a partial for the contents in the update panel.

I have read in the ASP docs that sometime validation controls bog down update panels but im not too sure if that's the problem here.

<div class="form-group">
        <asp:Label runat="server" AssociatedControlID="ddlFaculty" CssClass="col-md-2 control-label">Faculty</asp:Label>
        <div class="col-md-10">
           <asp:DropDownList ID="ddlFaculty" EnableViewState="true" class="form-control" CausesValidation="false" runat="server"  autopostback="true" aria-expanded="true" ValidationGroup="g4"  OnSelectedIndexChanged="ddlFaculty_SelectedIndexChanged">
                <asp:ListItem Value="null">Select Faculty</asp:ListItem>
                    <asp:ListItem Value="Arts">Faculty of Arts</asp:ListItem>
                    <asp:ListItem Value="Business">Faculty of Business</asp:ListItem>
                    <asp:ListItem Value="Health">Faculty of Health</asp:ListItem>                      
                    <asp:ListItem Value="Industries">Faculty of Service Industries</asp:ListItem>
                    <asp:ListItem Value="Trades">Faculty of Trades</asp:ListItem>
                    <asp:ListItem Value="Maori">Te Wananga Maori</asp:ListItem>
            </asp:DropDownList>
            <asp:RequiredFieldValidator runat="server" ControlToValidate="ddlFaculty" ValidationGroup="g4"
                CssClass="text-danger" Display="Dynamic" ErrorMessage="The faculty field is required." />                
        </div>
    </div>

    <div class="form-group">
        <asp:Label runat="server" AssociatedControlID="ddlCourse" CssClass="col-md-2 control-label">Course</asp:Label>
        <div class="col-md-10">
            <asp:UpdatePanel runat="server" id="UpdatePanel1" UpdateMode="Conditional">
                <ContentTemplate>
                    <asp:Label runat="server" id="lblfaculty"></asp:Label>
                    <asp:DropDownList runat="server" CssClass="form-control" ID="ddlCourse" ValidationGroup="g7" />
                </ContentTemplate>
                <Triggers>
                    <asp:AsyncPostBackTrigger ControlID="ddlFaculty" EventName="SelectedIndexChanged"/>
                </Triggers>
            </asp:UpdatePanel>
            <asp:RequiredFieldValidator runat="server" ControlToValidate="ddlCourse" ValidationGroup="g7"
                CssClass="text-danger" Display="Dynamic" ErrorMessage="The course field is required." />                
        </div>
    </div>
John Saunders
  • 160,644
  • 26
  • 247
  • 397

2 Answers2

1

Try using the AsyncPostBackTrigger property of the UpdatePanel.

See: How to stop UpdatePanel from causing whole page postback?

Did you try setting Button1 as an AsyncPostBackTrigger in the Triggers section, set the ChildrenAsTriggers property to true and the UpdateMode property to Conditional

Other solutions:

User control inside update panel causing full page postback

Full postback happens if your UpdatePanel cannot render its contents to a (e.g., when it is situated inside of ). So check you html inside of UpdatePanel, you might find the answer there (also, look for some incorrect xhtml, like incorrectly closed elements).

UpdatePanel causes full page postback

Unless you know of known issues that your site has when running in XHTML mode (and which you don't have time yet to fix), I'd always recommend removing the section from your web.config file (or you can explicitly set it to "Transitional" or "Strict").

This will make your HTML output standards compliant. Among other things, this will cause the HTML from your server controls to be "well formed" - meaning open and close tag elements always match. This is particularly important when you are using AJAX techniques to dynamically replace the contents of certain HTML elements on your page (otherwise the client-side JavaScript sometimes gets confused about container elements and can lead to errors). It will also ensure that ASP.NET AJAX works fine with your site.

Community
  • 1
  • 1
Justin Skiles
  • 9,373
  • 6
  • 50
  • 61
  • thanks for the coment but still after reading the articles it still is causing full page postback –  May 10 '15 at 21:57
0

It turns out that the page was infact sending a partial postback but I had mistaken the scroll to the top of the page when the postback had been recieved as a full page post back