[CLOSED] EXT.NET and ASP.NET MVC View Model

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1

    [CLOSED] EXT.NET and ASP.NET MVC View Model

    Hi Guys,

    I am trying to access the properties of my View Model but can't seem to get this to work with the EXT controls. please offer some assistance. The value from the model is not being displayed in the textbox.

    Below i am trying to access Model.Username from my LogOnModel view model.

    <%@ Page Language="C#"  Inherits="System.Web.Mvc.ViewPage<Ext.Net.MVC.Demo.Controllers.LogOnModel>"%>
    
    <%@ Register assembly="Ext.Net" namespace="Ext.Net" tagprefix="ext" %>
    
    
          <ext:Window 
            ID="LoginWindow"
            runat="server" 
            Closable="false"
            Resizable="false"
            Height="19" 
            Icon="Lock" 
            Title="Login"
            Draggable="true"
            Width="300"
            Modal="true"
            Layout="fit"
            BodyBorder="false"
            LabelAlign="Top"
            Padding="5">        
            <Items>
    
                    <ext:FormPanel ID="FormPanel1" 
                        runat="server" 
                        FormID="form1"
                        Border="false"
                        Layout="form"
                        BodyBorder="false" 
                        BodyStyle="background:transparent;" 
                        LabelAlign ="Top"
                        >
                        <Items>
                            <ext:TextField 
                                ID="UserName" 
                                runat="server" 
                                FieldLabel="<%$ Resources:WebResources|Account.FormControls, LabelUsername %>"
                                AllowBlank="false"
                                AnchorHorizontal="80%"
                                MsgTarget="Under"
                                Text = "<%= Model.Username %>"
                                />
                             <ext:TextField 
                                ID="Password" 
                                runat="server" 
                                InputType="Password" 
                                FieldLabel="<%$ Resources:WebResources|Account.FormControls, LabelPassword %>"
                                AllowBlank="false" 
                                AnchorHorizontal="80%"
                                MsgTarget="Under"
                                />
                             <ext:HyperLink
                                ID="ForgotPassword" 
                                runat="server"
                                Text="Forgot your password"
                                AnchorHorizontal="80%"
                                HideLabel ="true"
                                 />
                        </Items>
                    </ext:FormPanel>
            </Items>
            <Buttons>
                <ext:Button ID="Button1" runat="server" Text="Login" Icon="Accept">
                    <DirectEvents>
                        <Click 
                            Url="/Account/Login/" 
                            Timeout="60000"
                            FormID="form1"
                            CleanRequest="true" 
                            Method="POST"
                            >
                            <EventMask MinDelay="250" />
                            <ExtraParams>
                                <ext:Parameter Name="ReturnUrl" Value="Ext.urlDecode(String(document.location).split('?')[1]).r || '/'" Mode="Raw" />
                            </ExtraParams>
                        </Click>
                    </DirectEvents>
                </ext:Button>
            </Buttons>
        </ext:Window>

      public ActionResult Login()
            {
                LogOnModel model = new LogOnModel { UserName = "demo", Password = "demo" };
                return this.View(model);
            }
    Last edited by geoffrey.mcgill; Feb 18, 2011 at 6:24 PM. Reason: [CLOSED]
  2. #2
    Hi,

    1. Set AutoDataBind="true" for the TextField
    2. Use <%# %> syntax instead <%= %>

    <ext:TextField
            ID="UserName"
            runat="server"        
            AllowBlank="false"
            AnchorHorizontal="80%"
            MsgTarget="Under"
            AutoDataBind="true"
            Text="<%# Model.UserName %>"
            />
  3. #3

    Thanks alot

    Thanks a lot, you can mark this as solved...

Similar Threads

  1. [CLOSED] [Razor] Using Model in MVC View
    By UnifyEducation in forum 2.x Legacy Premium Help
    Replies: 3
    Last Post: May 02, 2012, 4:38 PM
  2. Replies: 1
    Last Post: Feb 01, 2012, 2:35 PM
  3. Replies: 2
    Last Post: Jan 10, 2012, 6:35 AM
  4. Using model var in mvc view
    By sinai.doron in forum 1.x Help
    Replies: 1
    Last Post: Nov 09, 2011, 5:19 PM
  5. [CLOSED] Null view model with PartialViewRenderer
    By paulc in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Feb 17, 2011, 7:30 AM

Posting Permissions