Akbari
Akbari

Reputation: 2409

Model binding for float fails

I'm trying to send window's position to the server. But model binding for top always fails. My action method is as below:

public void winClosed(Window position)

And the window model:

public class Window
{
    public decimal Left { get; set; }
    public double Top { get; set; }
}

In this picture you can see sample values:

window's positioin

And finally the JavaScript code:

var position = this.wrapper.offset();
$.post("@Url.Action("winClosed", "Home")", position);

The first line is relative to Kendo Window. I've already tried double, and float types in the model.

Upvotes: 0

Views: 598

Answers (1)

user3559349
user3559349

Reputation:

The decimal separator for your culture (fa-IR) is / (forward slash) character. You will need to replace the . character with a / character. For example

var offset = this.wrapper.offset();
var l = offset.left.toString().replace('.', '/');
var t = offset.top.toString().replace('.', '/');
$.post("@Url.Action("winClosed", "Home")", {left: l, top: t });

Upvotes: 1

Related Questions