Create a button to close a window

  1. #1

    Create a button to close a window

    Hey,
    I'm totally new in ext.net, and i've some difficulties to find documentation to help me, so sorry if the question seems too easy.

    I work with MVC, and I want to use the different helpers to create a windows with a button to close it in a renderpartial.
    I not find how to specify a function for the button, like "Window.Close()"

    How can i do this ?

    Here is my simple peace of code :

    var popup = Ext.Net.Html.X().Window()
               .ID("popup_error")
               .Title("An error occurs")
               .StyleHtmlContent(true)
               .ApplyBodyStyles("color : red")
               .Height(200)
               .Width(500)
               .AutoScroll(true)
               .AutoFocus(true);
    
           popup.Buttons((buttoncollection) =>
               {
                   var button = Ext.Net.Html.X().Button().Text("ok");
                   buttoncollection.Add(button);
               });
    
           popup.Render();
    Just want to make the "ok" button make close the windows without writing javascript function to do it

    Thanks in advance,
  2. #2
    Hello Orwel,

    Welcome to Ext.NET.

    The following sample demonstrates the Window configuration.

    Example

    @(    Html.X().Window()
            .ID("Window1")
            .Title("Error")
            .Height(100)
            .Width(200)
            .Buttons(buttons =>
            {
                buttons.Add(Html.X().Button()
                    .Text("OK")
                    .OnClientClick("App.Window1.close();"));
            })
        )
    When the Button is clicked, the Button will get a client-side instance of the Window Component (Window1), then call its .close() function. The client-side Components are available inside the 'App' Namespace. This helps organise the client-side objects.

    Hope this helps.
    Geoffrey McGill
    Founder
  3. #3
    Thanks a lot, it works ! Do you know where I can find any documentation about this ? Use helper seems very difficult because of these absence of documentation !

    I've another question about windows : it's about autoHeight. It's seems not to work. I've read their is a question of override the css, but just use .AutoHeight(true) does not work !
    I've already try to use .ApplyBodyStyles("height : auto;") or .ApplyStyles("height : auto") but both don't work. Any solution ? All solution I have found in the forum do not use helper.

    (Maybe i've to re open a thread for this discussion ?)

Similar Threads

  1. [CLOSED] how to close window after click button in this window
    By ViDom in forum 1.x Legacy Premium Help
    Replies: 8
    Last Post: Jun 22, 2012, 2:48 PM
  2. Replies: 2
    Last Post: May 15, 2012, 7:48 AM
  3. Create new window dynamically on button click from another window
    By softlabsgroup.support in forum 1.x Help
    Replies: 6
    Last Post: May 01, 2012, 9:26 AM
  4. [CLOSED] Desktop window close button on toolbar
    By llusetti in forum 1.x Legacy Premium Help
    Replies: 15
    Last Post: Jun 08, 2010, 6:41 PM
  5. Escape button doesn't close modal window
    By dbassett74 in forum Bugs
    Replies: 0
    Last Post: May 05, 2009, 8:26 PM

Tags for this Thread

Posting Permissions