小编Amm*_*han的帖子

多个DateTime参数的属性路由

我已经定义了属性路由,它将两个参数作为datetime

  [Route("{controller}/{action}/{*startDate:datetime}/{*endDate:datetime}")]
        public bool OverView(DateTime startDate,DateTime endDate)
        {
            var dt = startDate.ToString("yyyy-MM-dd");
            return true;
        }
Run Code Online (Sandbox Code Playgroud)

但不确定,它是如何可能的.属性路由适用于单个参数,但不确定它如何适用于2个参数.此外,很难知道如何将两个参数与网址区分开来

单一的param,工作正常

http://domain.com/Home/overview/2014/02/01

两个参数的网址是什么?我尝试了下面的一个,但有一个例外

http://domain.com/Home/overview/2014/02/01/2014/02/04

Exception
A catch-all parameter can only appear as the last segment of the route URL.
Parameter name: routeUrl
Run Code Online (Sandbox Code Playgroud)

asp.net-mvc attributerouting

6
推荐指数
1
解决办法
4552
查看次数

表格提交多次asp.net mvc

我在局部视图中有一个表单,通过进行ajax调用来提交.但问题是表单提交多个主题.我发现了非常奇怪的原因,我不知道如何解决它.

在主要观点中,

@Html.Partial("_Jobs", Model.UserJobs)

@section Scripts {

    @Scripts.Render("~/bundles/jqueryui")
    @Scripts.Render("~/bundles/jqueryval")
}
Run Code Online (Sandbox Code Playgroud)

我的部分观点我有一个表格

<script>

    function onSuccess() {
        $.fancybox.close();
        console.log("success");
        return false;
    }

    function onFailure() {
        alert("fail");
    }

</script>


@using (Ajax.BeginForm("CreateJob", "Jobs", null,
        new AjaxOptions()
            {
                HttpMethod = "POST",
                InsertionMode = InsertionMode.Replace,
                OnSuccess = "onSuccess",
                OnFailure = "onFailure",
                UpdateTargetId = "userJobsList"
            }, null))
{
    @Html.ValidationSummary()


        <div class="col-right">


            @Html.DropDownListFor(model => model.SelectedProjectId, Model.ProjectList, "Select an Option", new { @class = "text-box", id = "projects" })

            @Html.TextBoxFor(model => model.Title, new { @class = "text-box", placeholder = …
Run Code Online (Sandbox Code Playgroud)

asp.net-mvc jquery razor

2
推荐指数
1
解决办法
1423
查看次数

标签 统计

asp.net-mvc ×2

attributerouting ×1

jquery ×1

razor ×1