简体   繁体   English

转发器,Linkbutton和ModalPopupExtender无需回发

[英]Repeater, Linkbutton and ModalPopupExtender without postback

Here's my problem. 这是我的问题。

I have a repeater. 我有一个中继器。 Inside it has lots of textboxes. 里面有很多文本框。 In the right most column, there is a linkbutton. 在最右边的列中,有一个链接按钮。 This link button when clicked will show a modalpopupextender which will display the detail record of the selected row. 单击此链接按钮后,将显示一个modalpopupextender,它将显示所选行的详细记录。

I have made it work just fine but its slow because when you click the linkbutton, it will refresh the whole page. 我已经使其工作正常,但速度很慢,因为当您单击链接按钮时,它将刷新整个页面。

I don't want to reload the repeater because this is the part that is very slow. 我不想重新加载中继器,因为这是非常慢的部分。

I tried adding an updatePanel (repeater inside updatePanel) but ofcourse since the repeater is inside the updatePanel it will still reload the repeater. 我尝试添加一个updatePanel(位于updatePanel内的中继器),但是由于中继器位于updatePanel内部,因此它仍将重新加载中继器。

So the question is, how do I do it so when the linkbutton is clicked, it wont reload the repeater... 所以问题是,当单击链接按钮时,我该怎么办?它不会重新加载中继器...

Any ideas would be greatly appreciated. 任何想法将不胜感激。 By the way, I'm developing it with .net 2.0, c# 顺便说一下,我正在用.net 2.0,c#开发它

Try this one.

<asp1:UpdatePanel ID="updatepanel4" runat="server" >
<ContentTemplate>
 <table id="AssignedRequest" class="tablecont" runat="server" style="width: 900px;" >
 <tr>
   <td>
  <div style=" display:block; width:900px; height:350px;overflow:scroll; ">
    <asp:Repeater runat="server" ID="RepeaterRequest"> 
     <HeaderTemplate >
     <table class="list_table" border="0" cellpadding="0" cellspacing="0" width="100%">
    <tr>
        <th>Name</th>
        <th></th>
    </tr>
</HeaderTemplate>
<ItemTemplate>
  <tr>
    <td><%# Eval("NAME")%></td>

<td><a onclick="window.open(this.href,this.target,'directories=no,
     menubar=no,resizable=no,scrollbars=1,
     status=no,toolbar=no,addressbar=no,fullscreen=yes'); 
     return false;" href="View.aspx?name=<%#Eval("NAME")%>">View</a></td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>

</FooterTemplate>
</asp:Repeater>
</div>
</td>
 </tr>
</table>
 </ContentTemplate>
</asp1:UpdatePanel>

Register in the code behind, this code you add it after your bind, for example in your Page_Load, (You can also use ItemDataBound or ItemCreated delegate). 在后面的代码中注册,此代码是您在绑定之后添加的代码,例如在Page_Load中(您也可以使用ItemDataBound或ItemCreated委托)。

        rpt.DataBind();
        foreach (RepeaterItem ri in rpt.Items)
        {
            if (ri.ItemType == ListItemType.Item || ri.ItemType == ListItemType.AlternatingItem)
            {
                LinkButton lnkButton1 = (LinkButton)ri.FindControl("lnkButton1");
                ScriptManager1.RegisterAsyncPostBackControl(lnkButton1);
            }
        }

Why not go for something like a master-child relationship. 为什么不去做类似主子关系的事情呢? Do you require further interaction with the child data you are showing to the user? 您是否需要与显示给用户的子数据进一步交互? Please specify the nature if so. 如果是这样,请指定性质。

Assuming that the child data that you are going to show is simple data meant to simply convey related data to user, you can go for a combination jQuery, and repeaters to accomplish your objective. 假设您要显示的子数据是简单的数据,旨在将相关数据简单地传达给用户,则可以使用jQuery和中继器的组合来实现您的目标。

The first repeater you show your master data. 您将显示第一个转发器主数据。 Against each row in your repeater you show a show button here. 在中继器的每一行上,您在此处显示一个显示按钮。 You do not need a linkbutton here; 您在这里不需要链接按钮; just a simple anchor will do. 只需一个简单的锚即可。 You'd have to write js in it to toggle the correct child data. 您必须在其中编写js才能切换正确的子数据。

All the child data should also be repeated. 所有子数据也应重复。 But not shown to the user at first. 但一开始没有显示给用户。 Only that particular child item should be shown - this is suitably triggered by the show anchor which is clicked on the master repeater. 仅应显示该特定子项-通过在主中继器上单击的显示锚点适当触发。 Rest is all js/css. 其余都是js / css。

Below is a link to a sample project which demonstrates the concept. 下面是一个演示该概念的示例项目的链接。

http://www.coderun.com/ide/?w=2ObqOpjZz0qt7OrXYmmxwA http://www.coderun.com/ide/?w=2ObqOpjZz0qt7OrXYmmxwA

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM