locked
Visual Studio 2013 MVC View Scaffold... BUG? RRS feed

  • Question

  • User-16962349 posted

    I noticed a possible BUG while generating a view using the scafold.  If you generate a view using the "Create" template, there seems to be an unintended open <div class="form-group"> tag.  Here is an example after generating a view from a simple model class:

    @model FrommAdmin.Model.DDL
    
    @{
        ViewBag.Title = "Test";
    }
    
    <h2>Test</h2>
    
    @using (Html.BeginForm()) 
    {
        @Html.AntiForgeryToken()
        
        <div class="form-horizontal">
            <h4>DDL</h4>
            <hr />
            @Html.ValidationSummary(true)
    
            <div class="form-group">
            <div class="form-group">
                @Html.LabelFor(model => model.Type, new { @class = "control-label col-md-2" })
                <div class="col-md-10">
                    @Html.EditorFor(model => model.Type)
                    @Html.ValidationMessageFor(model => model.Type)
                </div>
            </div>
    
            <div class="form-group">
                @Html.LabelFor(model => model.Name, new { @class = "control-label col-md-2" })
                <div class="col-md-10">
                    @Html.EditorFor(model => model.Name)
                    @Html.ValidationMessageFor(model => model.Name)
                </div>
            </div>
    
            <div class="form-group">
                <div class="col-md-offset-2 col-md-10">
                    <input type="submit" value="Create" class="btn btn-default" />
                </div>
            </div>
        </div>
    }
    
    <div>
        @Html.ActionLink("Back to List", "Index")
    </div>

    The assumed uninteded div is on line 18.

    Cheers!

    - Jesse Lee 

    Wednesday, November 6, 2013 9:14 PM

Answers

  • User-166373564 posted

    HI,

    I tested Scaffold with simple example on my side, it creates the codes below,

    <div class="editor-label"> 
                    @Html.LabelFor(model => model.city) 
                </div> 
                <div class="editor-field"> 
                    @Html.EditorFor(model => model.city) 
                    @Html.ValidationMessageFor(model => model.city) 
                </div> 
        
                <p> 
                    <input type="submit" value="Create" /> 
                </p> 
            </fieldset> 
        } 
        
        <div> 
            @Html.ActionLink("Back to List", "Index") 
        </div>
    

    It doesn't act as yours, at the same time you could also consider reporting it in Microsoft Connect site. http://connect.microsoft.com/, our engineers will give positive response there.

    Regards

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, November 18, 2013 3:28 AM

All replies

  • User-166373564 posted

    HI,

    I tested Scaffold with simple example on my side, it creates the codes below,

    <div class="editor-label"> 
                    @Html.LabelFor(model => model.city) 
                </div> 
                <div class="editor-field"> 
                    @Html.EditorFor(model => model.city) 
                    @Html.ValidationMessageFor(model => model.city) 
                </div> 
        
                <p> 
                    <input type="submit" value="Create" /> 
                </p> 
            </fieldset> 
        } 
        
        <div> 
            @Html.ActionLink("Back to List", "Index") 
        </div>
    

    It doesn't act as yours, at the same time you could also consider reporting it in Microsoft Connect site. http://connect.microsoft.com/, our engineers will give positive response there.

    Regards

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, November 18, 2013 3:28 AM
  • User629347515 posted

    Same here.

    I create a model in the Model folder. Right click in the Controller folder -> Add -> Controller ...and I create the controller and the views (Create/Delete/Details/Edit/Index).

    In the Create view, I have the same <div class="form-group">, in the same position, to delete!

    Friday, December 27, 2013 6:33 PM