RazorGenerator不生成表单标记

时间:2014-12-10 16:12:53

标签: .net asp.net-mvc razorgenerator

谁能告诉我这里会发生什么?我有两个项目,都使用RazorMVC,并且都在.cshtml文件中使用相同的完全代码,但是没有输出<form>标记:

        <div id="attachmentAddFormArea" class="waitingOverlayParent">
            @using (Html.BeginForm("AddAttachment", "Attachment", FormMethod.Post, new { id = "attachmentAddForm", @class = "form-horizontal", role = "form", enctype = "multipart/form-data" }))
            {
                <div class="row form-group">
                    <label for="inputFile" class="col-sm-2 col-lg-2 control-label">Select File</label>
                    <div class="col-sm-7 col-lg-7">
                        <div class="btn btn-default btn-file">
                            Select<input type="file" id="inputFile" name="fileData" />
                        </div>
                        <input type="text" class="form-control btn-file-text" readonly />
                        <button type="button" id="attachmentSubmitBtn" class="btn btn-file-submit" name="Submit">Upload</button>
                    </div>
                </div>
                <div class="row  form-group">
                    <label for="@Html.IdFor(x => x.Description)" class="col-sm-2 col-lg-2 control-label">@Html.LabelFor(x => x.Description)</label>
                    <div class="col-sm-8 col-lg-8">
                        @Html.TextAreaFor(x => Model.Description, 5, 40, new { placeholder = "Enter Description", @class = "form-control" })
                        @Html.ValidationMessageFor(x => x.Description)
                    </div>
                </div>
            }
        </div>            

在非功能版中,这是输出:

        <div id="attachmentAddFormArea" class="waitingOverlayParent">
                <div class="row form-group">
                    <label for="inputFile" class="col-sm-2 col-lg-2 control-label">Select File</label>
                    <div class="col-sm-7 col-lg-7">
                        <div class="btn btn-default btn-file">
                            Select<input type="file" id="inputFile" name="fileData">
                        </div>
                        <input type="text" class="form-control btn-file-text" readonly="">
                        <button type="button" id="attachmentSubmitBtn" class="btn btn-file-submit" name="Submit">Upload</button>
                    </div>
                </div>
                <div class="row  form-group">
                    <label for="Description" class="col-sm-2 col-lg-2 control-label"><label for="Description">Description</label></label>
                    <div class="col-sm-8 col-lg-8">
                        <textarea class="form-control" cols="40" id="Description" name="Description" placeholder="Enter Description" rows="5"></textarea>
                        <span class="field-validation-valid" data-valmsg-for="Description" data-valmsg-replace="true"></span>
                    </div>
                </div>
        </div>

HELP! :)

1 个答案:

答案 0 :(得分:0)

我认为您可能遇到路由问题,这可以解释为什么它在一个项目中工作而不在另一个项目中工作。见这 - Form not generating