Question

Hello I have a view as below

<table class="adminContent">
    <tr>
        <td class="adminTitle">
            @Html.NopLabelFor(model => model.Published)
        </td>
        <td class="adminData">
            @Html.EditorFor(model => Model.Published)
            @Html.ValidationMessageFor(model => Model.Published)
        </td>
    </tr>
    <tr>
        <td class="adminTitle">
            @Html.NopLabelFor(model => model.SearchCategoryId)
        </td>
        <td class="adminData">
            @Html.DropDownList("SearchCategoryId", Model.AvailableCategories)
        </td>
    </tr>
    <tr>
        <td class="adminTitle">
            @Html.NopLabelFor(model => model.Price)
        </td>
        <td class="adminData">
            @Html.EditorFor(model => Model.Price)
            @Html.ValidationMessageFor(model => Model.Price)
        </td>
    </tr>
</table>

I've tried to set the price in javascript like that

$('#@Html.FieldIdFor(model => model.Price)').val('3333');

but it didnot reflect in the view also I need to reset the dropdownlist to use the 'All' option and to reset the checkbox

Was it helpful?

Solution

By default nopCommerce uses Telerik NumericTextBox. You cannot use jQuery "val" functiona to set its values. You did not spcify your nopCommerce version, so I presume you're using verion 3.30. It uses KendoUI (previously it used Telerik MVC Extensions). You can fidn it API here. It demonstrates how to set values for NumericTextBox

OTHER TIPS

The code you're showing is correct. That's the intended use of FieldIdFor, so the problem should be in the code you're not showing.

My first recommendation is to check the browser's console for errors and set a break-point with debugger;

To continue with this question you should give some more information about the context, for instance:

  • The javascript code that completes the block.
  • A sample of the rendered html code.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top