即使 gridview 位于更新面板中,整个页面也会刷新

发布于 2024-07-04 03:10:13 字数 194 浏览 6 评论 0原文

我有一个 gridview,它位于页面上的模式弹出窗口的更新面板内。
问题是,每次我单击网格视图中的图像按钮时,整个页面都会刷新。 这会导致我的整个页面加载,并且由于我已将页面的其余部分变灰,以便用户无法单击它,这非常烦人。

有谁知道我缺少什么。

编辑:我在底部输入了更好的解决方案

I have a gridview that is within an updatepanel for a modal popup I have on a page.
The issue is that the entire page refreshes every time I click an imagebutton that is within my gridview. This causes my entire page to load and since I have grayed out the rest of the page so that the user cannot click on it this is very annoying.

Does any one know what I am missing.

Edit: I entered a better solution at the bottom

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(11

一梦等七年七年为一梦 2024-07-11 03:10:13

确保您在 UpdatePanel 上进行了以下设置:
ChildrenAsTriggers=false 且 UpdateMode=Conditional

Make sure you have the following set on the UpdatePanel:
ChildrenAsTriggers=false and UpdateMode=Conditional

酒废 2024-07-11 03:10:13

UpdatePanel 上有 ChildrenAsTriggers="false" 吗?

页面上是否存在任何 JavaScript 错误?

do you have ChildrenAsTriggers="false" on the UpdatePanel?

Are there any javascript errors on the page?

风渺 2024-07-11 03:10:13

我遇到了这个问题并遇到了以下文章:

http://bloggingabout.net/blogs/rick/archive/2008/04/02/linkbutton-inside-updatepanel-results-in-full-postback-updatepanel -not-triggered.aspx

我的按钮不是像本例那样在代码中动态创建的,但是当我检查 aspx 中的代码时,它确实缺少 ID 属性。 添加 ID 后,回发变为异步并开始按预期运行。

所以,总而言之,检查你的按钮是否有一个 ID!

I had this problem and came across the following article:

http://bloggingabout.net/blogs/rick/archive/2008/04/02/linkbutton-inside-updatepanel-results-in-full-postback-updatepanel-not-triggered.aspx

My button wasn't dynamically created in the code like in this example, but when I checked the code in the aspx sure enough it was missing an ID property. On adding the ID the postback became asynchronous and started to behave as expected.

So, in summary, check your button has an ID!

物价感观 2024-07-11 03:10:13

作为参考..

我还注意到,当使用可怕的 时>,除了 UpdatePanel 上的 UpdateMode="Conditional" 之外,还需要进行以下其他更改:

  • ViewStateMode="Enabled" 是必需的 (我已在 MasterPage 中将其设置为 Disabled
  • ClientIDMode="必须从 <%@ Page .../> 中删除“Static”

For reference..

I've also noticed, when using the dreaded <asp:UpdatePanel ... /> and <asp:LinkButton ... />, that as well as UpdateMode="Conditional" on the UpdatePanel the following other changes are required:

  • ViewStateMode="Enabled" is required on <asp:Content ... /> (I've set it to Disabled in the MasterPage)
  • ClientIDMode="Static" had to be removed from <%@ Page ... />
薔薇婲 2024-07-11 03:10:13

UpdatePanel 可能对格式错误的 HTML 很敏感。 从浏览器中查看源代码,然后通过 W3C 验证器之类的工具运行它,以查找任何奇怪的内容(通常怀疑未封闭的 div 或表格)

。如果您使用 Firefox,则有一个 HTML 验证器扩展/附加组件可用,效果非常好。

UpdatePanels can be sensitive to malformed HTML. Do a View Source from your browser and run it through something like the W3C validator to look for anything weird (unclosed div or table being the usual suspects)

If you use Firefox, there's a HTML validator Extension/AddOn available that works quite nicely.

岁月如刀 2024-07-11 03:10:13

为了防止回发,请在 onclick 事件中添加 return false。

Button.attribute.add("onclick","返回 false;");

示例:

string PopupURL = Common.GetAppPopupPath() + "Popups/StockChart.aspx?s=" + symbol;
hlLargeChart.Attributes.Add("onclick", String.Format("ShowPopupStdControls(PCStockChartWindow,'{0}');return false;", PopupURL));

To prevent post-backs add return false to the onclick event.

button.attribute.add("onclick","return false;");

Sample:

string PopupURL = Common.GetAppPopupPath() + "Popups/StockChart.aspx?s=" + symbol;
hlLargeChart.Attributes.Add("onclick", String.Format("ShowPopupStdControls(PCStockChartWindow,'{0}');return false;", PopupURL));
总攻大人 2024-07-11 03:10:13

模态窗口是使用IE模态窗口弹出的吗? 或者你正在展示的是一个DIV?

如果它是 IE 模态弹出窗口,您需要确保

   <base target="_self" /> 

回发到模态页面。

如果它是 DIV,请确保您的 XHTML 正确,否则它可能不知道要更新什么。

Is the Modal Window popped up using the IE Modal window? Or is it a DIV that you are showing?

If it is an IE Modal Pop up you need to ensure you have

   <base target="_self" /> 

To make sure the post back are to the modal page.

If it is a DIV make sure you have your XHTML correct or it might not know what to update.

醉南桥 2024-07-11 03:10:13

我将保留 onClick 并将其设置为 updatePanel 的触发器。

奇怪的是它在 FF 中有效,但在 IE 中无效。 这与我们经历的行为相反。

I would leave the onClick and set it as the trigger for the updatePanel.

That's odd that it works in FF and not IE. That is opposite from the behavior we experience.

天邊彩虹 2024-07-11 03:10:13

几个月后,这个问题得到了解决。 我正在从事的项目是以前的v1.1,已转换为2.0。 然而,在 web.config 中,这一行仍然存在:

<xhtmlConformance mode="Legacy"/>

当它被注释掉时,我们似乎在 ajax 控制工具包中遇到的所有错误都消失了

Several months later this problem was fixed. The project I was working in was a previous v1.1 which was converted with 2.0. However, in the web.config this line remained:

<xhtmlConformance mode="Legacy"/>

When it was commented out all of the bugs that we seemed to have with the ajax control toolkit disappeared

无人问我粥可暖 2024-07-11 03:10:13

您是在 Firefox 还是 IE 中进行测试? 我们有一个类似的问题,整个页面在 Firefox(但不是 IE)中刷新。 为了解决这个问题,我们使用隐藏的 asp:button 并设置了 useSubmitBehavior="false"。

<asp:Button ID="btnRefresh" runat="server" OnClick="btnRefresh_Click" Style="display: none" UseSubmitBehavior="false" />

Are you testing in Firefox or IE? We have a similar issue where the entire page refreshes in Firefox (but not IE). To get around it we use a hidden asp:button with the useSubmitBehavior="false" set.

<asp:Button ID="btnRefresh" runat="server" OnClick="btnRefresh_Click" Style="display: none" UseSubmitBehavior="false" />
看海 2024-07-11 03:10:13

就我而言,这对我有用:

更改 web.config

    <xhtmlConformance mode="Transitional"/>

    'default.aspx 
    asp:GridView ID="GridView1" runat="server" Width="940px" 
    HorizontalAlign="Center" 
    OnRowCommand="GridView1_RowCommand" AutoGenerateColumns="false" 
    AllowPaging="true" PageSize="5"
    DataKeyNames="idarea" CssClass="table table-hover table-striped"
    OnPageIndexChanging="GridView1_PageIndexChanging" 

    'default.aspx.vb
   Protected Sub GridView1_PageIndexChanging(sender As Object, e As 
        GridViewPageEventArgs) Handles GridView1.PageIndexChanging
        BindGrid()
        GridView1.PageIndex = e.NewPageIndex
        GridView1.DataBind()
   End Sub

感谢您的提示。
路易斯·帕伦西亚

In my case this works for me:

change in the web.config

    <xhtmlConformance mode="Transitional"/>

    'default.aspx 
    asp:GridView ID="GridView1" runat="server" Width="940px" 
    HorizontalAlign="Center" 
    OnRowCommand="GridView1_RowCommand" AutoGenerateColumns="false" 
    AllowPaging="true" PageSize="5"
    DataKeyNames="idarea" CssClass="table table-hover table-striped"
    OnPageIndexChanging="GridView1_PageIndexChanging" 

    'default.aspx.vb
   Protected Sub GridView1_PageIndexChanging(sender As Object, e As 
        GridViewPageEventArgs) Handles GridView1.PageIndexChanging
        BindGrid()
        GridView1.PageIndex = e.NewPageIndex
        GridView1.DataBind()
   End Sub

Thanks for tip.
Luis Palencia

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文