Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/261.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# asp.net MVC web应用程序日期选择器不';行不通_C#_Jquery_Asp.net_Asp.net Mvc_Database - Fatal编程技术网

C# asp.net MVC web应用程序日期选择器不';行不通

C# asp.net MVC web应用程序日期选择器不';行不通,c#,jquery,asp.net,asp.net-mvc,database,C#,Jquery,Asp.net,Asp.net Mvc,Database,这是我的Create.cshtml文件 @model Bartering.Models.Advertisement @{ ViewBag.Title = "Create"; } <h2>Create</h2> <script src="@Url.Content("~/Scripts/jquery-1.7.1.js")" type="text/javascript"></script> <script src="@Url.Co

这是我的Create.cshtml文件

@model Bartering.Models.Advertisement


@{
    ViewBag.Title = "Create";
}

<h2>Create</h2>

<script src="@Url.Content("~/Scripts/jquery-1.7.1.js")" type="text/javascript"></script>

<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript">

</script>

<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" 

type="text/javascript"></script>

<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript">

</script>

<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" 

type="text/javascript"></script>

@using (Html.BeginForm("Create", "Advertisement", FormMethod.Post,  new { enctype="multipart/form-data" })) {
    @Html.ValidationSummary(true)
    <fieldset>
        <legend>TASK</legend>

        <div class="editor-label">
            @Html.LabelFor(model => model.Task_For)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Task_For)
            @Html.ValidationMessageFor(model => model.Task_For)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.UserName)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.UserName)
            @Html.ValidationMessageFor(model => model.UserName)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Department)
        </div>
        <div class="editor-field">
            @Html.DropDownListFor(model => model.Department,(SelectList)ViewBag.CategoryList)
            @Html.ValidationMessageFor(model => model.Department)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Attachment)
        </div>
        <div class="editor-field">
            <input type="file" id="MyFile" runat="server" />
            @Html.ValidationMessageFor(model => model.Attachment)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Description)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Description)
            @Html.ValidationMessageFor(model => model.Description)
        </div>
        <div class="editor-label">
            @Html.LabelFor(model => model.Date)
        </div>
       @inherits System.Web.Mvc.WebViewPage<System.DateTime?> 
       @Html.TextBox("", (Model.HasValue ? Model.Value.ToString("MM/dd/yyyy") : DateTime.Today.ToShortDateString()), new { @class = "datefield" })      
        <div class="editor-field">
            @Html.EditorFor(model => model.Date)
            @Html.ValidationMessageFor(model => model.Date)
        </div>


        <p>
            <input type="submit" value="Post"  />
        </p>
    </fieldset>
}

<div>
    @Html.ActionLink("Back to List", "Index")
</div>
当我运行应用程序时,会出现以下错误

The 'inherits' keyword is not allowed when a 'model' keyword is used.

Line 66:        @inherits System.Web.Mvc.WebViewPage<System.DateTime?>
使用“model”关键字时不允许使用“inherits”关键字。
第66行:@inherits System.Web.Mvc.WebViewPage
我想添加一个日期选择器来添加日期。如何解决此问题请帮助我解决此问题。

在您的视图中,您有

  @inherits System.Web.Mvc.WebViewPage<System.DateTime?> 
       @Html.TextBox("", (Model.HasValue ? Model.Value.ToString("MM/dd/yyyy") :

您不能同时使用inherit和model关键字…请查看此链接,我相信jQueryUI库丢失了。请尝试添加,让我们知道,如果它正在运行,请等待您的回复,但事实并非如此。@Farzi我引用了该链接,但不使用这两个关键字,我无法做到这一点。如果不同时使用这两个关键字,我无法做到这一点???@user2844981您已修复吗?或者你需要帮助吗?:)我没修好,我需要一个help@user2844981请您解释一下,当您删除继承时,什么不起作用?
  @inherits System.Web.Mvc.WebViewPage<System.DateTime?> 
       @Html.TextBox("", (Model.HasValue ? Model.Value.ToString("MM/dd/yyyy") :
@Html.TextBox("name", "value", new {type="date"})