locked
Update panel not partially postbacking. RRS feed

  • Question

  • User-394254955 posted

    <asp:updatepanel id="UpdatePanel1" runat="server"><contenttemplate></contenttemplate></asp:updatepanel>

    <asp:UpdatePanel ID="UpdatePanel1" runat="server"><ContentTemplate>
                <table style="text-align: center" width="960px" runat="server" id="accepttbl">
    
            <tr title="Reviewer's comment" style="width: 960px" id="txtboxreview" runat="server">
                <td>
                    <asp:Label ID="Labelreview" runat="server" Text="Reviewes / Comments : "></asp:Label>
                </td>
    
                <td colspan="2">
                    <asp:TextBox ID="txtReview" runat="server" Width="425px" TextMode="MultiLine" Style="width: 800px"></asp:TextBox>
                </td>
            </tr>
            <tr style="width:960px;">
                <td></td>
                 <td colspan="2">
                    <asp:TextBox ID="txtrevisionmail" runat="server" Visible="false" Width="425px" Rows="7" TextMode="MultiLine" Style="width: 800px" placeholder="Please write revision mail for the principal investigator"></asp:TextBox>
    
                </td>
            </tr>
            <tr style="width: 960px" runat="server" id="reviewaccept">
                <td>
                    <asp:Label ID="Label2" runat="server" Text="Accepted ? "></asp:Label>
                </td>
                <td>
                   
                    <asp:DropDownList ID="ddlStatus" runat="server" OnSelectedIndexChanged="ddlStatus_SelectedIndexChanged" AutoPostBack="true">
                        <asp:ListItem Value="0">NO</asp:ListItem>
                        <asp:ListItem Value="1" Selected="True">YES</asp:ListItem>
                    </asp:DropDownList>
                      
                </td>
               
                <td colspan="2">
                    <asp:Button ID="btnSubmitRevCom" runat="server" Text="Submit comment" CssClass="btn btn-primary" OnClick="btnSubmitRevCom_Click" />
                </td>
            </tr>
            <tr runat="server" id="officeremarks" visible="false">
                <td>
                    <asp:TextBox ID="txtoffcremark" Width="900px" runat="server" TextMode="MultiLine" Rows="5" placeholder="Office Remarks"></asp:TextBox>
    
                    <asp:Button ID="btnoffcremark" runat="server" Text="Submit Remarks" CssClass="btn btn-primary" OnClick="btnoffcremark_Click" />
    
                </td>
            </tr>
        </table>
          
        </ContentTemplate>
            <Triggers>
                <asp:AsyncPostBackTrigger ControlID="ddlStatus" EventName="SelectedIndexChanged"/>
            </Triggers>
        </asp:UpdatePanel>

    Source Code :
    
     protected void ddlStatus_SelectedIndexChanged(object sender, EventArgs e)
        {
            User loginUser = Session["LoginUser"] as User;
            ModuleSP msp = new ModuleSP();
            if (msp.HasAdminPrivilage(loginUser.Id, IntranetModules.EgrantAdmin))
            {
                if (loginUser.EmailId != "deanacad")
                {
                    if (ddlStatus.SelectedValue == "0")
                    {
    
                        txtrevisionmail.Visible = true;
                        //Email typing box display email goes when submit button press
                    }
                    else
                    {
                        txtrevisionmail.Visible = false;
                    }
                }
            }}


    <triggers> <asp:asyncpostbacktrigger controlid="ddlStatus" eventname="SelectedIndexChanged"></asp:asyncpostbacktrigger> </triggers>

    Tuesday, May 1, 2018 6:49 AM

All replies

  • User1724605321 posted

    Hi amrutha ,

    Please put a breakpoint in function `ddlStatus_SelectedIndexChanged` to confirm whether the function is fired , your code works on my side , code below is for your reference :

     <form id="form1" runat="server">
            <asp:ScriptManager ID="sc1" runat="server"></asp:ScriptManager>
            <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                <ContentTemplate>
                    <table style="text-align: center" width="960px" runat="server" id="accepttbl">
    
                        <tr title="Reviewer's comment" style="width: 960px" id="txtboxreview" runat="server">
                            <td>
                                <asp:Label ID="Labelreview" runat="server" Text="Reviewes / Comments : "></asp:Label>
                            </td>
    
                            <td colspan="2">
                                <asp:TextBox ID="txtReview" runat="server" Width="425px" TextMode="MultiLine" Style="width: 800px"></asp:TextBox>
                            </td>
                        </tr>
                        <tr style="width: 960px;">
                            <td></td>
                            <td colspan="2">
                                <asp:TextBox ID="txtrevisionmail" runat="server" Visible="false" Width="425px" Rows="7" TextMode="MultiLine" Style="width: 800px" placeholder="Please write revision mail for the principal investigator"></asp:TextBox>
    
                            </td>
                        </tr>
                        <tr style="width: 960px" runat="server" id="reviewaccept">
                            <td>
                                <asp:Label ID="Label2" runat="server" Text="Accepted ? "></asp:Label>
                            </td>
                            <td>
    
                                <asp:DropDownList ID="ddlStatus" runat="server" OnSelectedIndexChanged="ddlStatus_SelectedIndexChanged" AutoPostBack="true">
                                    <asp:ListItem Value="0">NO</asp:ListItem>
                                    <asp:ListItem Value="1" Selected="True">YES</asp:ListItem>
                                </asp:DropDownList>
    
                            </td>
    
                            <td colspan="2">
                                <asp:Button ID="btnSubmitRevCom" runat="server" Text="Submit comment" CssClass="btn btn-primary"  />
                            </td>
                        </tr>
                        <tr runat="server" id="officeremarks" visible="false">
                            <td>
                                <asp:TextBox ID="txtoffcremark" Width="900px" runat="server" TextMode="MultiLine" Rows="5" placeholder="Office Remarks"></asp:TextBox>
    
                                <asp:Button ID="btnoffcremark" runat="server" Text="Submit Remarks" CssClass="btn btn-primary"  />
    
                            </td>
                        </tr>
                    </table>
    
                </ContentTemplate>
                <Triggers>
                    <asp:AsyncPostBackTrigger ControlID="ddlStatus" EventName="SelectedIndexChanged" />
                </Triggers>
            </asp:UpdatePanel>
        </form>

    code behind :

      protected void ddlStatus_SelectedIndexChanged(object sender, EventArgs e)
            {
               
                        if (ddlStatus.SelectedValue == "0")
                        {
    
                            txtrevisionmail.Visible = true;
                            //Email typing box display email goes when submit button press
                        }
                        else
                        {
                            txtrevisionmail.Visible = false;
                        }
                 
               
            }

    Best Regards,

    Nan Yu

    Tuesday, May 1, 2018 7:02 AM
  • User-394254955 posted

    It fired only first time. when the second time selected index changed nothing will happen

    Tuesday, May 1, 2018 7:17 AM
  • User1724605321 posted

    Hi amrutha,

    It works on my side  . Have you trace the values in `ddlStatus_SelectedIndexChanged` method ? The second time that function will not get fired if you put a breakpoint ?

    Best Regards,

    Nan Yu

    Tuesday, May 1, 2018 7:28 AM
  • User-394254955 posted

    No.

    I think the something else, It is a very big project and It using Master pages. <g class="gr_ gr_64 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del" id="64" data-gr-id="64">May be</g> any conflict!!  Every page has this problem in <g class="gr_ gr_115 gr-alert gr_gramm gr_inline_cards gr_run_anim Grammar only-ins doubleReplace replaceWithoutSep" id="115" data-gr-id="115">update</g> panel.

    Tuesday, May 1, 2018 9:24 AM
  • User1724605321 posted

    Hi amrutha ,

    Yes, you need to check whether any conflict exists ,  update panel nesting will also cause that problem .

    Best Regards,

    Nan Yu 

    Wednesday, May 2, 2018 1:23 AM
  • User-394254955 posted

    Hi,

    Is there any code to avoid Conflict. or how to know where is the conflict

    Wednesday, May 2, 2018 4:57 AM
  • User1724605321 posted

    Hi amrutha ,

    The workaround is to use Ajax to call server side function :

    https://www.c-sharpcorner.com/UploadFile/dacca2/understand-jquery-ajax-function-call-code-behind-C-Sharp-method/ 

    https://www.aspsnippets.com/Articles/Call-Code-Behind-Server-Side-function-from-Client-Side-code-in-ASPNet-using-C-and-VBNet.aspx 

    Then change display attribute of the controls in success callback function with Ajax .

    Best Regards,

    Nan Yu

    Wednesday, May 2, 2018 8:38 AM
  • User-1171043462 posted

    IF you select same Item again SelectedIndexChanged won't fire. You need to select a different item each time

    Saturday, July 14, 2018 12:11 PM