Click here to Skip to main content
15,885,839 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi guys,

I was using update panel in a repeater,
n in repeater i have a button which will generate the report.

but when i use update panel, the button in the repeater is not working...

My Code:

<div class="form-horizontal well">
                                    <fieldset>
                                    <legend>Select Details</legend>
                                    <table>
                                    <tr>
                                    <td>Year</td>
                                    <td>
                                        <asp:TextBox ID="txtyear" CssClass="form-control" runat="server"></asp:TextBox>
                                    </td>
                                    <td>
                                    Select Month
                                    </td>
                                    <td>
                                        <asp:DropDownList ID="ddlmnth" CssClass="form-control" runat="server">
                                        </asp:DropDownList>
                                    </td>
                                    <td>
                                        <asp:Button ID="btnOK" runat="server" Text="OK" Width="80px" 
                                            CssClass="btn btn-sm btn-success" onclick="btnOK_Click" />
                                    </td>
                                    </tr>
                                    </table>
                                    </fieldset>
                                    </div>
                                    <br />
                                    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                                    <ContentTemplate>
                                    
                                    <asp:Repeater ID="Repeater1" runat="server">
                                     <HeaderTemplate>
                                                <table class="table table-bordered table-hover">
                                                    <thead class="bg-dark lt">
                                                        <tr>
                                                            <th>
                                                                S.No#
                                                            </th>
                                                            <th>
                                                                Project
                                                            </th>
                                                            <th>
                                                                Job Code
                                                            </th>
                                                            <th>
                                                                Status
                                                            </th>
                                                            <th>
                                                                Date
                                                            </th>
                                                            <th>
                                                                Action
                                                            </th>
                                                            
                                                        </tr>
                                                    </thead>
                                                    <tbody>
                                            </HeaderTemplate>
                                            <ItemTemplate>
                                                <tr id="itemrow">
                                                    <td valign="middle" style="width: 50px">
                                                        
                                                            <%# Container.ItemIndex + 1 %>
                                                        
                                                    </td>
                                                    <td>
                                                        "color: rgba(255, 165, 0, 1)">
                                                    </td>
                                                    <td>
                                                        ^__b>
                                                            <asp:Label ID="lblstatus" runat="server" Text='<%# Eval("status") %>'></asp:Label> 
                                                        
                                                    </td>
                                                    <td>
                                                        ^__b>
                                                           <%# Eval("Pdate") %>
                                                        
                                                    </td>
                                                    <td>
                                                        <asp:Button ID="btnrpt" CommandArgument='<%# Eval("RecID") %>' OnClick="btnrpt_Click" runat="server" Text="Report" CssClass="btn btn-sm btn-info" />
                                                    </td>
                                                    </tr>
                                                     </ItemTemplate>
                                            <FooterTemplate>
                                                </tbody> </table>
                                            </FooterTemplate>
                                    </asp:Repeater>
                                    
                                    </ContentTemplate>
                                    <Triggers>
                                    <%--<asp:AsyncPostBackTrigger ControlID="btnOK" />--%>
                                    <asp:PostBackTrigger ControlID="btnOK" />
                                    </Triggers>
                                    </asp:UpdatePanel>


code for report button:
protected void btnrpt_Click(object sender, EventArgs e)
        {
            int prjid = Convert.ToInt32(((Button)(sender)).CommandArgument.ToString());
            Response.Write("<script>");
            Response.Write("window.open('PrjDetails.aspx?RECID=" + prjid + "','_blank')");
            Response.Write("</script>");
        }

Can anyone plzzzz... help me.

Thanks
Posted
Updated 9-May-14 21:57pm
v4
Comments
Jignesh Khant 6-May-14 4:54am    
Are you using timer control on this page as well?
abdul subhan mohammed 6-May-14 5:02am    
No

You should not use Response object to execute client side scripts. Check this article
Use & Call RegisterStartUpScript, RegisterClientScript and Client-Side Script[^]
 
Share this answer
 
if you are generating some file for download then async postback will not work you need to have a full postback.
 
Share this answer
 
Comments
abdul subhan mohammed 6-May-14 5:06am    
i have tried both, AsynPostback n Postback trigger... but problem remains same

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900