Delete View Page

Unfortunately, we couldn't use the view page again like Edit view page. Therefore, we need to create a new HTML.

You could find the HTML template here: https://drive.google.com/open?id=0Bz2kPdGo45obQ0tEUm03Nm55SUU

Try to copy those code in Delete view page. Don't forget to declare model at the top of the code.

  1. If we Run our project, it seems the data is not dynamically changing.
  2. Let's take a look at snippet code in Delete view.
    <div class="row">
        <div class="col-xs-4 col-sm-3">
            <label>Date</label>
        </div>
        <div class="col-xs-8 col-sm-9">
            1/1/2016
        </div>
    </div>
    
  3. We should change the Date and Date variable dynamically.
    <div class="row">
        <div class="col-xs-4 col-sm-3">
            @Html.LabelFor(m => m.Date)
        </div>
        <div class="col-xs-8 col-sm-9">
            @Model.Date.ToShortDateString()
        </div>
    </div>
    
  4. Do above method to following attributes.
  5. To use a HTML helper method, we need to assign HTML.beginform() as we did earlier.
    @using (Html.BeginForm())
    {
        <div class="pad-top">
            <button type="submit" class="btn btn-danger btn-lg margin-right">
                <span class="glyphicon glyphicon-trash"></span> Delete
            </button>
            <a href="/" class="btn btn-warning btn-lg">
                <span class="glyphicon glyphicon-remove"></span> Cancel
            </a>
        </div>
    }
    
  6. When Cancel button being clicked, we want to be redirected to Index.

    <a href="@Url.Action("Index")" class="btn btn-warning btn-lg">
        <span class="glyphicon glyphicon-remove"></span> Cancel
    </a>
    

results matching ""

    No results matching ""