[CLOSED] Field value not posted to server if .Name() attribute present

  1. #1

    [CLOSED] Field value not posted to server if .Name() attribute present

    Hi,
    I set up some fields with .Name() attribute.

    X.NumberFieldFor(obj => obj.Discount_Amount)
                              .Name("m")
    X.NumberFieldFor(obj => obj.Tax_Amount)
                              .Name("m")
    I use name for some javascript function
    var fields = Ext.select('*[name=' m ']');
    but the problem is ,if .Name attribute present in field then when I submit its value not posted to server otherwise if remove this then I get the value.
    Last edited by Daniil; Oct 27, 2014 at 5:48 PM. Reason: [CLOSED]
  2. #2
    Hi @matrixwebtech,

    when I submit its value not posted to server
    Please clarify how you determine that.
  3. #3
    Hi Daniil ,Good morning,please see my example

    View

    @model e.Controllers.Fieldvaluenotpostedtoserver
    
    @{
       
       var X = Html.X();
     
    }
    @X.ResourceManager()
    
    @(X.FormPanel().ID("f")
        .Items(
                X.NumberFieldFor(obj=>obj.i)
                .Name("m")
                .ID("nf")
            )
            .Buttons(
                    Html.X().Button()
                    .ID("btnEdit")
                    .Text("Click")
                   
                    .DirectEvents(de =>
                    {
                        de.Click.FormID = "f";
                        de.Click.Action = "click";
                                  
                                 })
            )
    )
    Controller

    public class FieldvaluenotpostedtoserverController : Controller
        {
            //
            // GET: /Fieldvaluenotpostedtoserver/
    
            public ActionResult Index()
            {
                return View();
            }
    
            public void click(Fieldvaluenotpostedtoserver _obj)
            {
                
            }
    
        }
    
        public class Fieldvaluenotpostedtoserver
        {
            public  int i { get; set; }
        }
    Steps to reproduce
    1. run this code and put any numeric value to field and click on button.
    If you debug the code then you will get "0" in "_obj.i"
    2.comment .Name("m") from field and do same and you get appropriate value in "_obj.i"
  4. #4
    The NumberField's value is still in POST, but with the "m" key according to the Name property's value.

    "m" doesn't match any property of the Fieldvaluenotpostedtoserver class.

    For example, is there any reason why this POST
    SomeProperty: "some value"
    should go to this class?
    class SomeClass
    {
        public string AnotherProperty { ... }
    }
    "SomeProperty" doesn't match "AnotherProperty". The same happens with your test case. "i" doesn't match "m".
  5. #5
    Thanks danill ,I understand ,but as per my first post http://forums.ext.net/showthread.php...l=1#post206831 ,I have some fields bind with different viewmodel object.I assign same name attribute for some calculation with javascript

    var fields = Ext.select('*[name=' m ']');
    with above code I get all fields and loop through .can you please suggest me any another approach to solve both condition.

    This is just come to in my mind.if I use

    .InputAttrTpl(X.XTemplate().Html("Name=m"))
    then is it help full?
    Last edited by matrixwebtech; Oct 27, 2014 at 9:33 AM.
  6. #6
    I assign same name attribute for some calculation with javascript
    var fields = Ext.select('*[name=' m ']');
    You could use another attribute. The Name one is used as keys in POST. I guess you can use any other custom attribute.
  7. #7
    Thanks,you can close this thread now.
    but I not understand why you make this thread Sticky:?
  8. #8
    I have no idea how that happened:)

    No Sticky now.

Similar Threads

  1. [CLOSED] Set and Get Attribute and Value to a field
    By matrixwebtech in forum 2.x Legacy Premium Help
    Replies: 12
    Last Post: Oct 27, 2014, 5:19 PM
  2. [CLOSED] Tag field not present in MVC
    By matrixwebtech in forum 2.x Legacy Premium Help
    Replies: 6
    Last Post: Sep 25, 2014, 1:20 PM
  3. Replies: 6
    Last Post: Aug 11, 2011, 7:30 PM
  4. [CLOSED] [1.0] server side modification of an ext attribute
    By betamax in forum 1.x Legacy Premium Help
    Replies: 10
    Last Post: Mar 08, 2011, 1:08 PM
  5. [CLOSED] [1.0] Form field name attribute
    By SandorD in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Feb 22, 2010, 7:39 AM

Posting Permissions