更新面板问题 [英] Problem with update panel

查看:66
本文介绍了更新面板问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我在转发器中使用更新面板,

n在转发器中我有一个按钮会生成报告。



但是当我使用更新面板时,转发器中的按钮无效......



我的代码:



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>
                                                        
                                                            <%# Eval("ProjectName")%>
                                                        
                                                    </td>
                                                    <td>
                                                        
                                                           <%# Eval("PrjCode") %>
                                                        
                                                    </td>
                                                    <td>
                                                        
                                                            <asp:Label ID="lblstatus" runat="server" Text='<%# Eval("status") %>'></asp:Label> 
                                                        
                                                    </td>
                                                    <td>
                                                        
                                                           <%# 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

推荐答案

您不应使用 Response 对象来执行客户端脚本。查看这篇文章

使用&调用RegisterStartUpScript,RegisterClientScript和Client-Side Script [ ^ ]
You should not use Response object to execute client side scripts. Check this article
Use & Call RegisterStartUpScript, RegisterClientScript and Client-Side Script[^]


如果您要生成一些文件供下载,那么异步回发将无法运行,您需要完整的回发。
if you are generating some file for download then async postback will not work you need to have a full postback.


这篇关于更新面板问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆