Solution 1 :

My guess is form-control has the style display:block; and width:100%

Remove the above styles or override it using custom css below

.form-control.tablecellcustom {
 display: inline;
 width: auto;
}

after applying styles

I think your code internally uses Bootsrap. This is a guess, might be wrong. If its internally using Bootstrap you can try using input group also.

<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet" />
<div class="input-group mb-3">
  <span class="input-group-text">$</span>
  <input asp-for="g0" type="text" value="100000" class="form-control tablecellcustom" disabled>
</div>

Solution 2 :

I suspect your input is display block so you need to have a wrapper for your input and use flex box to achive this.

.form-control-wrapper {
  display: flex;
  align-items: center;
}

.form-control {
  margin-left: 5px;
}
<div class='form-control-wrapper'>
  $ <input class='form-control' />
</div>

Solution 3 :

The code you posted works as desired. Seems like you didn’t post the CSS which is applied.

Anyway, make sure the input element has display: inline or inline-block to appear in one line with the “$” symbol before it.

Solution 4 :

You can put value in the input value.
You can set a variable in value, also concatenate the string with $ before putting it
You can also set a label for that input then style it in CSS to be in the same line

<td>
   <input value={} asp-for="g0" type="text" class="form-control tablecellcustom" disabled>
</td>

Problem :

I have the following inside my asp.net core MVC view:-

<td>
   $<input asp-for="g0" type="text" class="form-control tablecellcustom" disabled>
</td>

where I am trying to display a $ sign beside an <input> on the same line, but currently, my above code will show the $ on a separate line as follow:-

enter image description here

Any advice on how I can show them on the same line?

Comments

Comment posted by tacoshy

input is an empty tag. it has no closing tag and also doesnt need a slash at the end.

Comment posted by Edvards Niedre

I was writing in XHTML 😉

Comment posted by Mcmananman

Then you can set in value={} you put here your variable. Also, you can concatenate the string with $ so you can get number + $.

By