1
I have an input field where I bring the value of the bank, which I use this way:
<input asp-for="TICMS" name="TICMS" onKeyPress="return(MascaraMoeda(this,'.',',',event))" class="form-control" />
However the following doubt arose: This field it is not changed by the user, it is only changed by means of accounts via javascript
then there is no need to appear as a textbox
, but I need him saved at the bank, because there may be changes, what would be the best way for him to appear ?
I tried something like:
@Html.Raw(model.TICMS);
But it does not save in the bank if it is this way. What is the best exit?
EDIT
If I take out the edges via css, and put readonly
the field stays like this:
but if the field cannot be changed, why does it have an event keypress?
– Ricardo Pontual
@Ricardopunctual was placed before these conditions. Before it was possible this change, as it is a standard account, it is made according to the data entered in the table, it is made via
javascript
, then it needs to be visible, and it needs to be saved in the bank.– Mariana
tried to use the parameter:
readonly="true"
– eKatsuro
understood. in this case, you can use another element, such as
span
for example, it accepts html as well– Ricardo Pontual
But this way I can change it
javascript
and save in the bank equal to the elementsinputs
?– Mariana
Pq doesn’t style it with CSS, removes the edges and leaves it readonly. It will look like text, but it will be a normal input that you can’t edit.
– LeAndrade
I have css, but if I put it in readonly the field is as if it had disabled, there is the appearance of the text box.
– Mariana
Yes you can, and also post the values for the model, just use the correct name/id according to the model. You can also use the attribute
readonly
in the input that will work, just can not disable because otherwise it will not be posted to the model.– Ricardo Pontual
@Ricardopunctual has some example to help me?
– Mariana
If it will never be changed, why not show in a
<span>
and have a<input type="hidden">
with that amount?– fernandosavio
Simply replace input by label:
<label asp-for="TICMS" name="TICMS" ....
– Ricardo Pontual