issues with parent page postback after closing child modal form

删除回忆录丶 提交于 2020-01-15 10:12:10

问题


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>

I have my RadWindowManager like this:

<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>

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();")

Which corresponds to this JS code:

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.

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

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.

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

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

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.

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


回答1:


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

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



来源:https://stackoverflow.com/questions/55817520/issues-with-parent-page-postback-after-closing-child-modal-form

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!