English 中文(简体)
在单一页面上使用多个更新小组而互不干涉
原标题:Using multiple UpdatePanels on a single page without interfering with each other
  • 时间:2012-05-24 16:30:16
  •  标签:
  • asp.net

似乎当多个更新小组位于一个页面上时, 每当一个 AsyncPostBack 在一个页面上出现时, 其他人都会重新加载他们的 html 。 是否有一条路可以绕过它?

示例

< 强度 > 示例. aspx

<asp:UpdatePanel ID="UpdatePanel1" runat="server"> 
    <ContentTemplate>
        <div style="border: 1px solid black;">
            <asp:TextBox runat="server" ID="txtTEST1" />
            <asp:Label runat="server" ID="lblTEST1" />
            <asp:Button runat="server" ID="btnTEST1" Text="AsyncPostBack1" />
            <div onclick="this.innerHTML= Wooo! ">Click Me - UpdatePanel1</div>
        </div>
    </ContentTemplate>
</asp:UpdatePanel>

<div onclick="this.innerHTML= Wooo! " style="padding: 1em;">Click Me. I m not part of an Update Panel</div>

<asp:UpdatePanel ID="UpdatePanel2" runat="server"> 
    <ContentTemplate>
        <div style="border: 1px solid black;">
            <asp:TextBox runat="server" ID="TextBox1" />
            <asp:Label runat="server" ID="Label1" />
            <asp:Button runat="server" ID="Button1" Text="AsyncPostBack2" />
            <div onclick="this.innerHTML= Wooo! ">Click Me - UpdatePanel2</div>
        </div>
    </ContentTemplate>
</asp:UpdatePanel>

< 强度 > 示例. aspx.vb

Protected Sub btnTEST1_Click(sender As Object, e As EventArgs) Handles btnTEST1.Click
    lblTEST1.Text = "Refreshed at " & DateTime.Now.ToString()
End Sub

Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    Label1.Text = "Refreshed at " & DateTime.Now.ToString()
End Sub

<强度 > 测试问题

  1. Click on all 3 of the divs with the "Click Me" text so that HTML is altered inside and outside of the UpdatePanels.
  2. Click one of the buttons labeled "AsyncPostBack". Regardless on which one is clicked, both UpdatePanels will have their HTML rerendered and replaced, as seen by the 2 divs inside the UpdatePanels resetting to their original text.

所以我要问, 能否在同一页上设置多个更新小组, 以免每次出现一个 AsyncPostBack 事件时彼此重复 。

最佳回答

是 是

  1. set updatemode=conditional
  2. provide the triggers which will trigger the update. here is a link to an example. (#1 result on google) http://ajax.net-tutorials.com/controls/updatepanel-control/
问题回答

尝试添加模式以更新面板标签。 如果模式不给默认模式总是。 如果“ 更新模式” 属性始终是 。 如果“ 更新模式” 属性始终是, 更新后的小组控制内容会更新到页面上从任何地方开始的每个后退内容 。 < a href=\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

<asp:UpdatePanel ID="BugsListUpdatePanel" runat="server" UpdateMode="Conditional">




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!