[CLOSED] [1.0] Couple MVC questions and property questions

  1. #1

    [CLOSED] [1.0] Couple MVC questions and property questions

    I'm fairly new to MVC development using Ext.Net, so these might be some basic questions I'm asking here, but...

    First, question I'm messing around with the Ext.Net MVC Demo that you guys provided. My question is that in Account/Login.aspx view there is a property on the Click DirectEvent of button that says CleanRequest="true". Can you explain what this property means and does?

    Second, In the MVC example, I notice you guys created a FormPanel and reference the panel in the Click event of the DirectEvent of the button using FormID. The [HttpPost] Login action of the AccountController has the username, password, returnUrl properties. Does the FormPanel automatically add the FormPanel values to the parameter list to pass back to the Account/Login action? Is it better than just adding the values to the ExtraParameters of the Click DirectEvent? What are the advantages and/or disadvantages of doing either/or?

    Finally, in the FormPanel there is a Url='<%# Html.AttributeEncode(Url.Action("Login")) %>'. Can you tell me the purpose of the Url property at the FormPanel level, when there is already as a Url on the Button's Directevent Click method that references the Post method Login action of the AccountController?

    Thanks again.
    Last edited by Daniil; Dec 31, 2010 at 6:27 PM. Reason: [CLOSED]
  2. #2
    Hi,

    First, question I'm messing around with the Ext.Net MVC Demo that you guys provided. My question is that in Account/Login.aspx view there is a property on the Click DirectEvent of button that says CleanRequest="true". Can you explain what this property means and does?
    By default, DirectEvent sent all extra params as special json object and ResourceManager parse it. In many cases (like MVC controller action), it is not very usefult because MVC engine cannot parse that object and maps it to action attributes. Therefore we have to use CleanReaquest="true" which force sending extra params as 'key=value' (like form fields). Please note that CleanRequest is true by default if you work under ASP.NET MVC and direct event has defined Url

    Second, In the MVC example, I notice you guys created a FormPanel and reference the panel in the Click event of the DirectEvent of the button using FormID. The [HttpPost] Login action of the AccountController has the username, password, returnUrl properties. Does the FormPanel automatically add the FormPanel values to the parameter list to pass back to the Account/Login action? Is it better than just adding the values to the ExtraParameters of the Click DirectEvent? What are the advantages and/or disadvantages of doing either/or?
    DirectEvent submits a form (html form or form panel) (if a form is presented). The behaviour (submit or not) is defined by Type property: Submit (submit a form) and Load (don't submit a form, only extra params will be submitted). In many cases, direct event can automatically find a form for submit (find up in the dom hierarchy) but in some cases we have to define the form manually (set form id in the FormID property)
    So, if you need to submit particuar params only then use Type="Load" and ExtraParameters (in this case, request size will be small), if you need to submit all form fields and extra parameters then use Type="Submit" (default, less coding but request size is much more)

    Finally, in the FormPanel there is a Url='<%# Html.AttributeEncode(Url.Action("Login")) %>'. Can you tell me the purpose of the Url property at the FormPanel level, when there is already as a Url on the Button's Directevent Click method that references the Post method Login action of the AccountController?
    FormPanel has built in functionality to submit own values. You can define url and use
    FormPanel1.getForm().submit();
    Please see
    http://dev.sencha.com/deploy/dev/doc...sicForm-submit

    Use that property is not really required if you use DirectEvent functionality instead FormPanel built in functionality
  3. #3
    Related to the same topic, I have also a question.

    Using MVC, I have the choice between DirectEvents and controller actions. Now my question is, when to use which of them.

    Let's say I want to change the theme. For now I use a DirectEvent as follows:

     
    <script runat="server">
        // Change theme and save to profile
        protected void ChangeTheme(object sender, DirectEventArgs e)
        {
            // Change actual theme 
            ResourceManager.GetInstance(this.Page).SetTheme((Theme)Enum.Parse(typeof(Theme), e.ExtraParams["myTheme"]));
            // Save users favorite theme to profile
            Profile.Preferences.Theme = e.ExtraParams["myTheme"];
            // Show users actual theme 
            Notification.Show(new NotificationConfig
            {
                Title = Resources.Default.Theme,
                Icon = Icon.Information,
                Html = Resources.Default.ThemeChanged
            });
        }
    </script>
    But let's say I want to move that code on a controller..... I tried an failed... How can I adress the current ResourceManager from a controller?

    Best regards, Flavio
  4. #4
    Hi,

    ResourceManager is placed inside Page (View) which is inaccessable in the controller because page/view is not created in the controller. In the controller you have to register required javascript
    return new AjaxResult(string.Format("Ext.net.ResourceMgr.setTheme({0}, {1});", JSON.Serialize(new ResourceManager().GetThemeUrl(Theme.Slate)), JSON.Serialize(Theme.Slate)));
    Also, the following topic can be interesting for you
    http://forums.ext.net/showthread.php...ll=1#post47580
  5. #5
    Agree, in that case I think DirectEvent is the better way to have clear serverside code.

    A further question on the MVC subproject:
    When I should use RenderExtPartial OR PartialViewResult in a controller? The controller extension is not visible in my project, is that beacause it is still at work?

    Best regards, Flavio
  6. #6
    Hi,

    RenderExtPartial is extension method for HtmlHelper class, you can use it to render partial views inline inside another view, like
    <%= Html.RenderExtPartial("Partial/View", Model, "Panel1") %>
    To see that extension method you have add 'using' to the codebehind
    using Ext.Net.MVC;
    or Import for the view
    <%@ Import Namespace="Ext.Net.MVC" %>

Similar Threads

  1. [CLOSED] Questions
    By farisqadadeh in forum 1.x Legacy Premium Help
    Replies: 5
    Last Post: Mar 27, 2011, 9:45 AM
  2. Questions
    By fredba in forum Licensing
    Replies: 1
    Last Post: Jun 15, 2010, 6:19 PM
  3. [CLOSED] [1.0] Couple of v1.0 questions...
    By state in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Oct 16, 2009, 4:08 PM
  4. Some questions
    By Kipetcoff in forum 1.x Help
    Replies: 3
    Last Post: Feb 17, 2009, 3:25 AM
  5. Coolite - Thank you and a couple questions
    By ColdSun in forum Open Discussions
    Replies: 3
    Last Post: Jun 30, 2008, 6:36 PM

Tags for this Thread

Posting Permissions