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

Ajax + window modal

1 Answer 65 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Zbigniew Kozłowski
Top achievements
Rank 1
Zbigniew Kozłowski asked on 24 Oct 2010, 02:28 PM
Hi,
i've got a question, because im new to asp.net. Im trying to port mine app from WPF to ASP.NET, but got few issues. Im doing full ajax app, and i dont know how to achiv such scenario:

1. Default.aspx with RadWindowManager and a DIV that will contain website later.
2. Login.aspx just a form with login, pass and a button (it appears in RadWindow)
3. xxxx.aspx after successful login

so basicly in Default.cs i got 

protected void Page_Load(object sender, EventArgs e)
        {
            SessionUser sessionUser = (SessionUser)Session["User"];
            if (sessionUser == null)
            {
                ShowLoginWindow();
            }
        }

ShowLoginWindow() just open a RadWindow and till that everything works fine. Than in Login.aspx i use RadAjaxManager with button control to get click. Mine question starts here
1. How can i close RadWindow form code-behind.
2. How can i know at code-behind Default.cs that Login Window is closed, so i can load a site into DIV?

Also how do you use modal window? Im not talking about lock screen, because there is a bool to make modal or not, but how can i do something at code-behind, than forward data to modal window, get data from window and continue to execute code.
Something like:

Window window = new Window();
window.MineString = "Something";
window.ShowDialog();
MessageBox.Show(window.OtherString);

Ofc i know it cant be achiv like i did, but need something for such scenario.

Thanks, for help.

1 Answer, 1 is accepted

Sort by
0
Accepted
Georgi Tunev
Telerik team
answered on 26 Oct 2010, 12:30 PM
Hello Zbigniew,

Straight to your questions:
  1. To close a RadWindow from within the content page, you need to get a reference to it and then call its close() method - basically, in the same way as you would do that with a standard popup. The only difference is that to get a reference to the RadWindow, you need to use the GetRadWindow() function instead of using the window object.
    function GetRadWindow()
    {
      var oWindow = null;
      if (window.radWindow)
         oWindow = window.radWindow;
      else if (window.frameElement.radWindow)
         oWindow = window.frameElement.radWindow;
      return oWindow;
    }             
     
    function closeWin()
    {
        var oWnd = GetRadWindow();
        oWnd.close()
    }
  2. RadWindow is created and handled on the client - it doesn't have a server-side event fired when it is closed (if it did, you would have to make trips to the server on every closing). If you want to fire a server-side event when a RadWindow is closed, you could use the OnClientClose property. There you could set a name of a JavaScript function that will be fired once the window is closed. In that JS function, you could use __doPostBack() or RadAjax's ajaxRequest call.

Best wishes,
Georgi Tunev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
General Discussions
Asked by
Zbigniew Kozłowski
Top achievements
Rank 1
Answers by
Georgi Tunev
Telerik team
Share this question
or