Question

When you want to create a DateTime picker control with JQWidgets, you must define a div element and then call a function like this using Javascript:

$("#MyDivElementId").jqxDateTimeInput().

The problem is: I'm not able to figure out how I can use Model Binding of Asp.Net MVC with this syntax. I mean, the Model Binding feature will try to match key-value pair received from input controls in the form element and obviously, div element are not input control.

I found somebody who already resolved this problem using hidden field set with values of matching div JQWidgets element before submitting form but I don't like this solution; it's not natural and I must write to much code for a thing that should be simpler in my view.

Does anybody have more elegant solution?

Was it helpful?

Solution

If you set the "name" attribute of the DIV tag, the value from the DateTimeInput's Input tag would be submitted.

OTHER TIPS

First of all when you submit id is not submited and i just opened that plugin demo. when you add code $("#MyDivElementId").jqxDateTimeInput(). it will create textarea with name MyDivElementId and when you submit then you will have the same value on server side. Other issue can be with date format since they would be probably different on client side and server side.

try to add input parameter for controller "DateTime MyDivElementId" and check if its null or not.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top