关闭子模式表单后父页面回发的问题 [英] issues with parent page postback after closing child modal form

查看:75
本文介绍了关闭子模式表单后父页面回发的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用ASP.NET应用程序,但遇到了无法解决的问题.我有一个名为 Form1.aspx 的父表单,其中包含一个 Telerik RadGrid .在页面加载时,此网格完全为空.用户可以通过单击添加来添加数据,在这种情况下,Rad窗口将打开:这是我的代码:

I'm working on an ASP.NET application and I ran into an issue that I am unable to resolve. I have a parent form, called Form1.aspx which contains a Telerik RadGrid. On page load, this grid is completely empty. The user has the ability to add data, by clicking add, in this case a Rad Window opens: here's my code:

<td >
     <input id="btnAdd" runat="server" onclick="showQuestion4()"
      type="button" value="Add" />
</td>

我有这样的 RadWindowManager :

<telerik:RadWindowManager ID="RequestsRadWindowManager" runat="server" >
  <Windows>
    <telerik:RadWindow ID="ClientQuestion4" runat="server" Behaviors="Close,Move" 
      EnableEmbeddedSkins="false" Height="300px" Modal="true" OnClientClose="OnClientClose" 
      ReloadOnShow="true" Skin="WebBlue" Width="550px">
    </telerik:RadWindow>
  </Windows>
</telerik:RadWindowManager>

然后使用我的JS函数实际打开窗口:

And My JS function to actually open the window:

function showQuestion4() {
    return window.radopen("mdClientQ4.aspx?mode=add", "ClientQuestion4", "return false;");
    return false;
}

我的子窗体可以正确打开,并允许用户输入和保存数据.用户单击保存"后,我将进行插入,然后将其命名为:

My child form opens correctly, and allows user to enter and SAVE data. Once user clicks SAVE, I do an insert and then call this:

RadAjaxManager1.ResponseScripts.Add("cancelAndClose();")

对应于以下JS代码:

function cancelAndClose() {
var oWnd = GetRadWindow();
oWnd.close();
}

function GetRadWindow() {
  var oWindow = null;
  if (window.radWindow) oWindow = window.radWindow;
  elseif(window.frameElement.radWindow)oWindow=window.frameElement.radWindow;
  return oWindow;
}

因此该代码被调用,我的子窗体成功关闭,现在焦点返回到在后台打开的父"窗体.

So this code gets called, my child form Closes successfully, and now the focus returns to my Parent form which has been open in the background.

这里发生的事情是,我在父表单上有整页帖子,我的主要目标是防止IT攻击.

What's happening here is, I have a Full Page Post back on the parent form, and my main goal is to PREVENT IT.

我的 RadGrid 当前位于更新面板中,具有 mode ="conditional" .此 Update Panel 的触发器是一个下拉菜单,它启用了ADD按钮,从而允许用户打开子窗体并输入数据.

My RadGrid is currently in Update Panel, with mode="conditional". The trigger for this Update Panel is a dropdown, which enabled the ADD button , which in turns allows the user to open the child form and enter data.

我一直在尝试禁用此 postback 数小时,但无济于事,我不知道这是我做错了什么.

I have been trying to disable this postback for hours to no avail, I have no idea what it is I'm doing wrong.

我在我的 showQuestion4() Javascript函数中设置了 return false; ,但这仍然会被忽略,并且父页面具有完整的页面加载力.

I set return false; in my showQuestion4() Javascript function, but this still gets bypasses, and the parent page has full page load.

为此,我的目标是关闭子窗体,而不会在父窗体中发生POST BACK,而是我想简单地使用RadGrid重新加载 UpdatePanel ,这将显示以下信息:用户在子"表单中输入.

My goal for this, is to close the child form, and NOT have the POST BACK occur in my parent form, rather I want to simply reload the UpdatePanel with RadGrid which would display the information the user entered in the Child form.

任何帮助或提示将不胜感激.如有必要,我很乐意显示更多代码.

Any help or tips will be greatly appreciated. I'd be more than happy to show more code if necessary.

根据下面的Nikkis评论,我从 btnAdd 中删除了 runat ="server" ,但是,我的父表单仍然通过回发

Per Nikkis comment below, I removed runat="server" from btnAdd however, my parent form still goes through postback

推荐答案

发布为答案,因为看起来您是从我们的评论对话中得出的.

Posting as an answer, since it looks like you worked it out from our comment conversation.

检查UpdatePanel,并确保在客户端关闭时调用的所有代码都按照您的意图被触发.

Check the UpdatePanel, and be sure any code called on client close is firing as you mean it to fire.

这篇关于关闭子模式表单后父页面回发的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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