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

Oct 25, 2014, 8:06 PM
I set up some fields with .Name() attribute.

X.NumberFieldFor(obj => obj.Discount_Amount)

X.NumberFieldFor(obj => obj.Tax_Amount)

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.

Oct 27, 2014, 6:06 AM
Hi @matrixwebtech,

when I submit its value not posted to server

Please clarify how you determine that.

Oct 27, 2014, 6:34 AM
Hi Daniil ,Good morning,please see my example


@model e.Controllers.Fieldvaluenotpostedtoserver


var X = Html.X();



.DirectEvents(de =>
de.Click.FormID = "f";
de.Click.Action = "click";



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"

Oct 27, 2014, 8:24 AM
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".

Oct 27, 2014, 8:36 AM
Thanks danill ,I understand ,but as per my first post http://forums.ext.net/showthread.php?45621-Field-value-not-posted-to-server-if-Name%28%29-attribute-present&p=206831&viewfull=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


then is it help full?

Oct 27, 2014, 5:25 PM
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.

Oct 27, 2014, 5:36 PM
Thanks,you can close this thread now.
but I not understand why you make this thread Sticky:?

Oct 27, 2014, 5:48 PM
I have no idea how that happened:)

No Sticky now.