ASP.NET Webforms UpdatePanel重复内容 [英] ASP.NET Webforms UpdatePanel duplicate contents

查看:98
本文介绍了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重复内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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