Using beforeshow/beforerender events with controller actions

  1. #1

    Using beforeshow/beforerender events with controller actions

    Hi Guys,

    I've got a desktop application built with Ext.NET. There is a particular module that I want to show a popup window the first time they open it.

    I've got all the controller actions set-up to allow this (controller will generate window if a database field is a certain value), but the part I am stuck on is showing the window before showing the module.

    Is there anyway you can think of to call this controller action before showing the module? I've tried to put in a
    DirectEvents.BeforeRender.Action
    call in the module but it seems like that only stops rendering when you return false from a javascript event, not a controller action.
  2. #2
    I just tried setting the module window to hidden and then un-hiding it when you click out of the pop-up window, but that seems to minimize the window to the task bar. And when you click on it to maximize it you get an 'Uncaught TypeError: Cannot read property 'dom' of undefined'.

    This method seems promising but that error seems to stop me in my tracks.

    Here's some code for that method

    ViewModel
    public class TestViewModel : Window
        {
            public TestViewModel()
            {
                DirectEvents.BeforeRender.Action = "Test/Test";
                ID = "Test_Window";
                Title = "Test";
                Width = 1200;
                Height = 1000;
                Border = false;
                Layout = LayoutType.Fit.ToString();
                CloseAction = CloseAction.Hide;
                Stateful = true;
            }
        }
    Controller
    public class TestController : Controller
        {
            // GET: Test/Test
            public ActionResult Index()
            {
                var win = X.GetCmp<Window>("Test_Window");
                
                var accepted = CheckServiceAgreement();
    
                if (!accepted)
                {
                    win.Hidden = true;
                    Window window = new Window
                    {
                        ID = "serviceWindow",
                        Title = "Service Agreement",
                        Height = 185,
                        Width = 350,
                        BodyPadding = 5,
                        Modal = true,
                        CloseAction = CloseAction.Destroy,
                        Html = "BLAHBLAHBLAHBLAHBLAHBLAHBLAH"
                    };
                    window.Buttons.Add(new Button()
                    {
                        DirectClickAction = "Test/Test/AcceptServiceAgreement",
                        Text = "Agree"
                    });
                    window.Render(RenderMode.Auto);
                }
    
                return this.Direct();
            }
    
            public bool CheckServiceAgreement()
            {
                //Checks if user has accepted
            }
    
            public ActionResult AcceptServiceAgreement()
            {
               //accepts
    
                var win = X.GetCmp<Window>("serviceWindow");
    
                win.Close();
    
                var window = X.GetCmp<Window>("Test_Window");
                window.Hidden = false;
                return this.Direct();
            }
        }
  3. #3
    Hi @thebadcodeguy,

    You are explaining everything quite thoroughly, but sorry, I cannot get the requirement very well. Could you, please, provide a full sample that would demonstrate the requirement?

Similar Threads

  1. [CLOSED] Controller Event Domain related events are not fired
    By shahidmughal in forum 2.x Legacy Premium Help
    Replies: 7
    Last Post: Aug 09, 2014, 2:38 AM
  2. Replies: 4
    Last Post: Apr 11, 2014, 4:31 PM
  3. Replies: 11
    Last Post: Apr 04, 2013, 4:49 AM
  4. [CLOSED] BeforeRender is not working when added from code behind
    By Aparna_B in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Apr 18, 2012, 4:08 PM
  5. Replies: 6
    Last Post: Nov 30, 2011, 6:48 PM

Tags for this Thread

Posting Permissions