ASP.NET Webforms UpdatePanel重复内容

编程入门 行业动态 更新时间:2024-10-26 21:19:55
本文介绍了ASP.NET Webforms UpdatePanel重复内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我已经得到了一个我试图理解的庞大Webforms项目,但是我遇到了一个问题,其中更新面板正在复制很多内容.面板的aspx代码巨大,长数百行,但基本上看起来像这个简单的示例,只包含更多的 asp:TextBox 和 asp:ListBox .

I've been handed a huge Webforms project which I'm trying to understand, and I have a problem where an Update Panel is duplicating a lot of its content. The aspx code for the panel is huge, hundreds of lines long, but it basically looks like this simple example, only with lots more asp:TextBox and asp:ListBox.

<asp:UpdatePanel runat="server" ChildrenAsTriggers="true" RenderMode="Block" UpdateMode="Conditional"> <ContentTemplate> <div><table><tbody><tr><td> <label>Search</label><asp:TextBox ID="Search" runat="server" /> <asp:LinkButton runat="server" OnClick="find_Click" >Find</asp:LinkButton> </td></tr></tbody></table></div> <div id="a"><table><tbody><tr><td> <label>Result</label><asp:TextBox ID="Result" runat="server" /> </td></tr></tbody></table></div> </ContentTemplate> </asp:UpdatePanel>

和类似的代码.

public void find_Click(Object sender, EventArgs e) { Result.Text = "oranges"; }

当您单击LinkBut​​ton时,我希望在结果中看到< div id ="a"> 部分,但在TextBox中带有文本"oranges".您实际得到的是带有'oranges'的< div id ="a"> ,然后是带有的原始< div id ="a"> 空的TextBox.最糟糕的是,在这个简单的示例中,甚至在我创建的页面中都没有原始的 asp:TextBox 和 asp:ListBox 的页面中,都没有这样做但充满了伪数据.谁能指出我解决该问题的任何好方法?

When you click the LinkButton, I would expect to see in the result the <div id="a"> section, but with the text 'oranges' in the TextBox. What you actually get is <div id="a"> with 'oranges', followed by the original <div id="a"> with the empty TextBox. The worst bit is that it doesn't do it in this simple example, nor even in a page that I created that had all the original asp:TextBox and asp:ListBox but filled with dummy data. Can anyone point me to any good ways of approaching this problem?

推荐答案

您可能已经尝试过此方法,但是在实际的问题页面中,是否可以从updatepanel中删除尽可能多的服务器控件,而只留在有问题的文本框中然后看看会发生什么?我猜想您可能必须注释掉很多.cs/.vb代码,这可能会很痛苦.

You might have already tried this, but in the actual problem page, is it possible to remove as many server controls out of the updatepanel and just leave in offending textbox and then see what happens? I'm guessing you'll probably have to comment out alot of .cs/.vb code, which can be a pain.

也请尝试删除updatepanel,然后看看会发生什么情况.

Also try removing the updatepanel and see what happens.

更多推荐

ASP.NET Webforms UpdatePanel重复内容

本文发布于:2023-11-25 00:21:24,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1627532.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:内容   NET   ASP   UpdatePanel   Webforms

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!