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

change to Taghelper

$
0
0

I would like to change the Form and the dropdownlist to Select Taghelper to the new Taghelper but I can not understand, I got this code from the web and is working, but I don't like it  it is not readable to me, if the code in the controller is needed I can put it, I did not put it because I don't want to be to excessive

@model Bueno.ViewModels.Compras.CompraOrderViewModel

@using (Html.BeginForm("CategoryChosen", "Home",
                                                    FormMethod.Post))
{
    <table cellspacing="2" cellpadding="2">
        <tr>
            <td>
                <input type="number" name="qty" size="10" />
            </td>
            <td>
                @Html.DropDownList("CategoryType", "Categorias")
            </td>
        </tr>

        <tr>
            <td>
                Sub Category:
            </td>
            <td>
                @Html.DropDownList("SubCategory", new SelectList(string.Empty, "conceptoId", "name"), "Please select a Sub Category", new { style = "width:250px" })
            </td>
            <td>
                <input type="number" name="price" size="10" />
            </td>
            <td>
                <input type="submit" value="Add" class="btn btn-default" />
            </td>
        </tr>
    </table>
}

<script src="~/lib\jquery\dist/jquery.min.js"></script>
<script type="text/javascript">

    $(document).ready(function () {

        $("#CategoryType").change(function () {
            $("#SubCategory").empty();
            $.ajax({

                type: 'POST',

                url: '@Url.Action("GetSubCategories")',
                dataType: 'json',
                data: { id: $("#CategoryType").val() },
                success: function (subcategories) {

                    $.each(subcategories, function (i, subcategory) {

                        $("#SubCategory").append('<option value="'
                            + subcategory.Value + '">' +
                            subcategory.Text + '</option>');
                    });
                },
                error: function (ex) {
                    alert('Failed to retrieve Sub Categories : ' + ex);
                }
            });
            return false;
        })
    });
</script>


Viewing all articles
Browse latest Browse all 9386

Trending Articles



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