This is a migrated thread and some comments may be shown as answers.

After I close a radwindow can I change the parent window URL?

7 Answers 280 Views
Window
This is a migrated thread and some comments may be shown as answers.
matt
Top achievements
Rank 1
matt asked on 16 Jul 2008, 02:47 PM
I have a radwindow with some links to different things. I want to be able to click on a link and then have the radwindow close (got this part working)

and then in the parent page I want a code behind method to be called so I can look at the value sent back from the RadWindow and Response.Redirect to certain URL.

Is this possible?

I looked on the forum here already and didnt see anything regarding this issue. help

7 Answers, 1 is accepted

Sort by
0
matt
Top achievements
Rank 1
answered on 16 Jul 2008, 04:42 PM
http://www.telerik.com/DEMOS/ASPNET/Prometheus/Controls/Examples/Integration/GridAndWindow/DefaultCS.aspx?product=grid

and I looked there

all I want is after I click a linkbutton in the radwindow someway to get in the codebehind of the parent page so I can do a response.redirect and what I need to do

0
Georgi Tunev
Telerik team
answered on 17 Jul 2008, 01:16 PM
Hi matt,

I would suggest to check the Using RadWindow as a Dialog topic in the documentation - there you can see how to return arguments from the dialog on the parent page.
Sending these arguments from the client to the server is out of the scope of the RadWindow control - this is a general ASP.NET task. You can find more information on how to call a server-side function via Javascript in various places in the Net (the asp.net forums are a good place to start). For example you can use __doPostBack() or RadAjax's ajaxRequest call to do this.


Sincerely yours,
Georgi Tunev
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
matt
Top achievements
Rank 1
answered on 17 Jul 2008, 03:58 PM
I understand the 2 parts you mention.

Part 1 is passing the variables back and forth in Javascript from the popup back to the parent. I see some good examples

Part 2 is I think I need to call the javascript doPostback so it will go back to the server and I suppose there is some way to pass a javascript variable to the server

So do I have the basic ideas right?

This seems kind of unusual what I am doing so unfortuntly I cannot find any examples of anyone doing something similiar :(

I posted on asp.net . Hopefully that will help
0
Georgi Tunev
Telerik team
answered on 18 Jul 2008, 09:12 AM
Hello Matt,

Yes, you got the idea right. As for sending arguments to the server with __doPostback() (note the 2 underscores in front), I suggest to check the following article:
http://aspalliance.com/895_Understanding_the_JavaScript___doPostBack_Function.all
which offers a very good explanation on the logic that should be used.



Best of luck,
Georgi Tunev
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
matt
Top achievements
Rank 1
answered on 18 Jul 2008, 04:12 PM
I foudn another article that mentioned a way that seemed easier.. How about using

<asp:LinkButton ID="lb" runat="server" OnClientClick="OpenSelfClosingRadWindow();return false;" Text="Alerts and Announcements" />

to open a window then using

<asp:Button OnClick="Button1_Click" Runat="server" Text="Postback page and close on reload" id="Button1"></asp:Button>

<

asp:Label ID="lblScript" Runat="server"></asp:Label>

and

protected void Button1_Click(object sender, System.EventArgs e)

{

lblScript.Text =

"<script>CloseOnReload()</" + "script>";

}

That works great.

but then the problem with that is I am using a collection of linkbuttons and NOT just one button. so I capture the onClick for the link clicked and say

lblScript.Text =

"<script>CloseOnReload()</" + "script>";

and that DOES NOT work

Any idea why? Using those javascrpit functions seemed easier that onpostback

and about onpostback how do I get back to the calling pages javascript?

0
Shaun Peet
Top achievements
Rank 2
answered on 19 Jul 2008, 05:38 AM

To use the calling page's code...

Say the parent page has a js function like so:

function doSomething() { alert('Hello!); }

The window's page needs to get a reference to the window object, and then use the BrowserWindow object to get the parent page, which is then used to call the function on the parent page.  So, the window page needs to have the following script:

function get_RadWindow() {   
  var oWindow = null;   
  if (window.radWindow) {   
   oWindow = window.radWindow;   
  }   
  else if (window.frameElement.radWindow) {   
    oWindow = window.frameElement.radWindow;   
  }   
  return oWindow;   
}  
 
function callParentAndClose {  
  get_RadWindow().BrowserWindow.doSomething();  
  get_RadWindow().Close();  

Hope that helps,

Shaun.

0
Shaun Peet
Top achievements
Rank 2
answered on 19 Jul 2008, 05:44 AM
By the way, I would also suggest that you do the following...

Add a RadAjaxManager to the page that is opened by the window, and add the buttons (or linkbuttons) to the collection of controls that are ajaxified by the RadAjaxManager.  Then, you can use the server-side event for the buttons / linkbuttons to execute client-side code after a click happens.  So, you'll end up with:

Protected Sub Button1_Click(object sender, System.EventArgs e) {
  RadAjaxManager1.ResponseScripts.Add("CloseOnReload()");
}

I think you'll find that this is extremely fast and will get rid of any screen flicker caused by your postback, and it's also quite easy to do.  Hope that helps,

Shaun.
Tags
Window
Asked by
matt
Top achievements
Rank 1
Answers by
matt
Top achievements
Rank 1
Georgi Tunev
Telerik team
Shaun Peet
Top achievements
Rank 2
Share this question
or