Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

Changing htmlhelpers to TagHelpers

$
0
0

I am practicing in the sample Project by Rowan Miller named UnicronStore, and I am trying to change the views from htmlhelpers to taghelpers

I am having trouble when submit save, with htmlhelpers it Works well, but with the tag helpers it stays in the same page and does not make any changes,

here is the code

This one Works fine

@using (Html.BeginForm())

{

@Html.AntiForgeryToken()

<divclass="form-horizontal">

<h4>Bulk Price Reduction</h4>

<hr/>

@Html.ValidationSummary(true,"",new { @class = "text-danger" })

<divclass="form-group">

@Html.LabelFor(model => model.CategoryId,"CategoryId", htmlAttributes: new { @class = "control-label col-md-2" })

<divclass="col-md-10">

@Html.DropDownList("CategoryId",null, htmlAttributes: new { @class = "form-control" })

@Html.ValidationMessageFor(model => model.CategoryId,"",new { @class = "text-danger" })

</div>

</div>

<divclass="form-group">

@Html.LabelFor(model => model.PercentageOffMSRP, htmlAttributes:new { @class = "control-label col-md-2" })

<divclass="col-md-10">

@Html.EditorFor(model => model.PercentageOffMSRP,new { htmlAttributes = new { @class = "form-control" } })

@Html.ValidationMessageFor(model => model.PercentageOffMSRP,"",new { @class = "text-danger" })

</div>

</div>

<divclass="form-group">

<divclass="col-md-offset-2 col-md-10">

<inputtype="submit"value="Save"class="btn btn-default"/>

</div>

</div>

</div>

But this one does not

<form>

<divclass="form-horizontal">

<h4>Bulk Price Reduction</h4>

<hr/>

<divasp-validation-summary="ValidationSummary.All"class="text-danger"></div>

<divclass="form-group">

<labelasp-for="CategoryId"class="control-label col-md-2">CategoryId</label>

<divclass="col-md-10">

<selectasp-for="CategoryId"asp-items="ViewBag.CategoryId"class="form-control">CategoryId</select>

<spanasp-validation-for="CategoryId"class="text-danger"></span>

</div>

</div>

<divclass="form-group">

<labelasp-for="PercentageOffMSRP"class="control-label col-md-2">Percetngae</label>

<divclass="col-md-10">

<inputasp-for="PercentageOffMSRP"class="form-control"/>

<spanasp-validation-for="PercentageOffMSRP"class="text-danger"></span>

</div>

</div>

<divclass="form-group">

<divclass="col-md-offset-2 col-md-10">

<inputtype="submit"value="Save"class="btn btn-default"/>

</div>

</div>

</div>

</form>


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>