HTML view of the field

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 has arisen: This field is not changed by the user, it is only changed by means of accounts via javascript so there is no need to appear as a textbox , however I need it to be saved in bank, as there may be changes, what would be the best way for it to appear? I've tried something like:

 @Html.Raw(model.TICMS);

But he does not save in the bank if he is this way. What's the best way out?

EDIT

If I draw the borders via css, and I put readonly the field looks like this:

    
asked by anonymous 12.09.2018 / 13:39

2 answers

2

First of all, transforming input into something that does not look like a input , I think it's not suitable ... But if that's what you want here has an example that can serve you.

I think you're using Bootstrap, because I noticed the form-control class in your input so I had to consider this in the CSS I made. First I gave all:unset to try to clean up the default styles of Bootstrap's input , but Bootstrap's CSS hierarchy is very strong and I needed to use some !important to remove everything !

See how it looks in the template below:

.form-control.labelcss {
    all:unset;
    border:none !important;
    box-shadow:none !important;
    outline: none !important;
    background-color: #fff !important;
    display: inline-block;
    margin-bottom: 5px;
    font-weight: 700;

}
    <link rel="stylesheet" type="text/css" media="screen" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" />

        <input asp-for="TICMS" value="input customizado" name="TICMS" onKeyPress="return(MascaraMoeda(this,'.',',',event))" readonly class="form-control labelcss" />
        <label for="">isso é um label</label>
        <input asp-for="TICMS" value="input padrão com readonly" readonly name="TICMS" onKeyPress="return(MascaraMoeda(this,'.',',',event))"  class="form-control" />
    
12.09.2018 / 14:27
0

<input asp-for="TICMS" name="TICMS" onKeyPress="return(MascaraMoeda(this,'.',',',event))" class="form-control" type="hidden"/>

Put it as type="hidden" , so the user will not see it, but it will be there:)

    
12.09.2018 / 13:42