Home > Net >  get value from a hidden field in mvc view, value already set
get value from a hidden field in mvc view, value already set

Time:08-09

@Html.Hidden("cinDays") 

From inspect element:

<input id="cinDays" name="cinDays" type="hidden" value="127">

The value from #cinDays I want to be a parameter for a .cs C# method. This method is called inside an @if statement in my view

CodePudding user response:

In the JavaScript function you can access the value like below:

function yourfunc() {
    let param = $("#cinDays").val();   
    // Now using the `param` value 
    ... 
}

CodePudding user response:

As I understand cinDays is a part of view model so you can access to this property like this

...

<div>
      @if(someFunc(Model.cinDays)) {
       //some code
      }
</div>

...
  • Related