RazorGenerator Not Generating Form Tag

162 views Asked by At

Can anyone tell me what might be going on here? I have two projects, both using RazorMVC, and both using this same exact code in the .cshtml file, but one doesn't output the <form> tag:

        <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>            

In the non-functional version, this is the output:

        <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

There are 1 answers

0
AudioBubble On

I think you may have an issue with routing, that would explain why it works in one project and not the other. See this - Form not generating