Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Triggers in UpdatePanel

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 405
    Comment on it

    While using pop-up in your code you need to use update panel for that.

     

    So if you have server side controls inside that pop-up sometimes these events are not triggered as usual because of update panel.

     

    What you need to do is to use triggers for invoking these events which are not accessible directly from your code

     

     

    --- Script manager is added to run the AJAX control like update panel

     

       <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    
    
    -- The content in which we want to reduce the postback should be put inside update panel
    
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>
    <asp:GridView ID="grdDetails" runat="server"  Width = "550px"
    AutoGenerateColumns = "false"  AlternatingRowStyle-BackColor = "#C2D69B"  
    HeaderStyle-BackColor = "green" AllowPaging ="true"
    OnPageIndexChanging = "OnPaging" 
    PageSize = "10" >
    <Columns>
    <asp:BoundField DataField = "logid" HeaderText = "Customer ID" HtmlEncode = "true"  />
    <asp:BoundField DataField = "username" HeaderText = "Name"  HtmlEncode = "true" />
    <asp:BoundField DataField = "category" HeaderText = "Category"  HtmlEncode = "true"/> 
            <asp:BoundField DataField = "email" HeaderText = "Email"  HtmlEncode = "true"/> 
        <asp:BoundField DataField = "active" HeaderText = "Status"  HtmlEncode = "true"/> 
    <asp:TemplateField ItemStyle-Width = "30px"  HeaderText = "Change">
       <ItemTemplate>
           <asp:LinkButton ID="lnkEdit" runat="server" Text = "Edit" OnClick = "Edit"></asp:LinkButton>
       </ItemTemplate>
    </asp:TemplateField>
    </Columns> 
    <AlternatingRowStyle BackColor="#C2D69B"  />
    </asp:GridView>
    
    
    <asp:Panel ID="pnlAddEdit" runat="server" CssClass="modalPopup" style = "display:none">
    <asp:Label Font-Bold = "true" ID = "Label4" runat = "server" Text = "Customer Details" ></asp:Label>
    <br />
    <table align = "center">
    
    <tr>
    <td>
    <asp:Label ID = "Label5" runat = "server" Text = "Customer ID" ></asp:Label>
    </td>
    <td>
    <asp:TextBox ID="txtCustomerID" runat="server"></asp:TextBox>    
    </td>
    </tr>
    
    <tr>
    <td>
    <asp:Label ID = "Label2" runat = "server" Text = "Contact Name" ></asp:Label>
    </td>
    <td>
    <asp:TextBox ID="txtContactName" runat="server"></asp:TextBox>    
    </td>
    </tr>
    <tr>
    <td>
    <asp:Label ID = "Label3" runat = "server" Text = "Category" ></asp:Label>
    </td>
    <td>
    
        <asp:DropDownList ID="ddlCategory" runat="server"></asp:DropDownList>
    
    <%--<asp:TextBox ID="txtCompany" runat="server"></asp:TextBox>--%>
    </td>
    </tr>
        <tr>
    <td>
    <asp:Label ID = "Label1" runat = "server" Text = "Email" ></asp:Label>
    </td>
    <td>
    <asp:TextBox ID="txtEmail" runat="server"></asp:TextBox>
    </td>
    </tr>
    
    
            <tr>
    <td>
    <asp:Label ID = "Label6" runat = "server" Text = "Status" ></asp:Label>
    </td>
    <td>
    
     <asp:DropDownList ID="ddlStatus" runat="server"></asp:DropDownList>
    </td>
    </tr>
    
    
    <tr>
    <td>
    <asp:Button ID="btnSave" runat="server" Text="Save" OnClick = "Save" />
    </td>
    <td>
    <asp:Button ID="btnCancel" runat="server" Text="Cancel" OnClientClick = "return Hidepopup()"/>
    </td>
    </tr>
    </table>
    </asp:Panel>
    <asp:LinkButton ID="lnkFake" runat="server"></asp:LinkButton>
    <cc1:ModalPopupExtender ID="popup" runat="server" DropShadow="false"
    PopupControlID="pnlAddEdit" TargetControlID = "lnkFake"
    BackgroundCssClass="modalBackground">
    </cc1:ModalPopupExtender>
        <br />
        <br />
        <br />
    </ContentTemplate> 
    <Triggers>
    <asp:AsyncPostBackTrigger ControlID = "grdDetails" />
    <asp:AsyncPostBackTrigger ControlID = "btnSave" />
    </Triggers> 
    </asp:UpdatePanel> 
    

     

     

    In the above example we have made a grid that is used for adding items into the grid.

    For adding items into the grid we have used the Modalpopup extender that will contain the HTML controls for saving the values through it.

    AsyncPostBackTrigger  is used to reduce the postback into the updatepanel.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: