1

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

Koosh
  • 876
  • 13
  • 26
  • 1
    The server doesn't need a post from that button click on btnAdd, does it? If not, remove the runat=server from there. I think that's why it's doing what you describe. Also, your function has two return statements; you can remove that second one, it's not being hit. – Nikki9696 Apr 23 '19 at 19:52
  • If the answer from @Nikki9696 doesn't help, the best place to get help on this is on the Telerik forums; they provide really great tech support there. Here's their Window forum: https://www.telerik.com/forums/aspnet-ajax/window – Alex Apr 23 '19 at 19:55
  • @Nikki9696 i removed runat="server" still doing postback :( – Koosh Apr 23 '19 at 19:59
  • @Alex i don't have the login info. And I gotta go to VP to get it, you know how that'd look. – Koosh Apr 23 '19 at 20:01
  • 1
    Totally understand:) Then stick with the answers here. – Alex Apr 23 '19 at 20:04
  • I notice you mention update panel, which is not really my thing (I do mvc) but I did find this - maybe promising? https://stackoverflow.com/questions/728043/how-to-stop-updatepanel-from-causing-whole-page-postback – Nikki9696 Apr 23 '19 at 20:11
  • 1
    similar scenario but mine is prompted by the fact that I close the modal window, i tried the solution but it doesn't work in my case. I swear if I can't figure this out I'm switching careers :) @Nikki9696 – Koosh Apr 23 '19 at 20:28
  • hmmm. what does this do? OnClientClose="OnClientClose" – Nikki9696 Apr 23 '19 at 20:49
  • 1
    @Nikki9696 that's where the problem was! I was calling a function to update the UpdatePanel with the grid. What was happening is I was simply doing __PostBack('UpdatePanel',''), but what I had to do is add .ClientID to update panel and now everything is great. If you want to post some kind of an answer since you were helpful I will gladly mark it as answer – Koosh Apr 24 '19 at 17:07

1 Answers1

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.

Nikki9696
  • 6,260
  • 1
  • 28
  • 23