[CLOSED] Model Binding POSTed combobox values

  1. #1

    [CLOSED] Model Binding POSTed combobox values

    Hi,

    I'm using model binding to automatically map form POST values into my object. This works perfectly, except when comboxes are submitted. They provide an 'xxxxxx_value' key which is the actual ValueField I need to capture. When I bind (using default MVC modelbinder), it doesn't use this _value property; instead (I presume) using the name property I specify, which is a string - and therefore returns 0 in my bound object.

    eg:

     <ext:ComboBox ID="cboActionFunction" runat="server" FieldLabel="Function" LabelAlign="Right"
                                StoreID="storeActionFunctions" DisplayField="ActionFunctionTitle" ValueField="Id"
                                DataIndex="ActionFunctionId" AllowBlank="false" X="5" Y="5" Width="200" ForceSelection="true"
                                SelectOnFocus="true" Name="ActionFunctionId" EmptyText="Set function"
                                ListWidth="150" Mode="Local">
    Controller:

     public ActionResult SaveAction(Models.Action act, int? hitlistId, int? actionId) {
    ....
    }
    The act object looks great, except combo values equal 0, as the _value property is not picked up, the DisplayField part is instead:

            ActionForId    0    int
            ActionFunctionId    0    int
            ActionStatusId    0    int
            ActionSubject    "A test subject"    string
            ActionTypeId    0    int
    Apologies if this is more my misunderstanding of the MVC function; I'm not sure if it's an ext.net quirk or not.
    Last edited by Daniil; Mar 13, 2012 at 5:32 PM. Reason: [CLOSED]
  2. #2
    Hi,

    Please clarify do you use Ext.NET v2?
  3. #3
    Quote Originally Posted by Daniil View Post
    Hi,

    Please clarify do you use Ext.NET v2?
    Ah! I'm sorry, I didn't meant to post in 2x forums. I'm still using 1.3. Sorry.
  4. #4
    I've came across a workaround (perhaps not a workaround, maybe ext.net is doing it correctly?) if anyone is interested.

    HiddenName="ActionFunctionId" HiddenValue="this.getValue()"
    This submits the value I want with just the name ActionFunctionId, which the model expects to be an int and so it binds it correctly.
  5. #5
    Yes, you should set up a respective HiddenName.

    Also, I think setting
    HiddenValue="this.getValue()"
    is not required.
  6. #6
    Quote Originally Posted by Daniil View Post
    Yes, you should set up a respective HiddenName.

    Also, I think setting
    HiddenValue="this.getValue()"
    is not required.
    Confirmed. The HiddenValue part is not needed. Can you clarify, I have in this same formpanel a TopBar with some comboboxes. These don't appear to be submitted at all, is this the standard behaviour due to being in a toolbar/topBar?
  7. #7
    A field is submitted automatically when it's within a <form> HTML element.

    I guess you use
    FormPanel1.getForm().submit()
    and there is no main
    <form runat="server">
    on your page.

    In this case, FormPanel creates its own <form> HTML element and its TopBar is not within that <form>, so, TopBar fields are not submitted. Only FormPanel Items are submitted in this case.

    Hope this helps.

Similar Threads

  1. [CLOSED] binding checkbox selection model
    By CarpFisher in forum 2.x Legacy Premium Help
    Replies: 3
    Last Post: Jul 18, 2012, 7:52 AM
  2. Replies: 1
    Last Post: Nov 06, 2011, 10:27 AM
  3. FormCollection values not being posted
    By GLD in forum 1.x Help
    Replies: 8
    Last Post: Apr 21, 2011, 11:02 PM
  4. [CLOSED] MVC, Binding model to Store
    By SymSure in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Apr 08, 2011, 3:19 PM
  5. binding checkbox selection model
    By VipulTyagi in forum 1.x Help
    Replies: 2
    Last Post: Apr 07, 2011, 11:36 AM

Tags for this Thread

Posting Permissions