Method that outputs an HTML input element of type="text". For views in ASP.Net MVC
Questions tagged [html.textboxfor]
109 questions
32
votes
2 answers
What is readonly for in a disabled TextBoxFor?
I have two different ways to use a DISABLED TextBoxFor, which is:
@Html.TextBoxFor(u => u.Visibilidade, new { disabled = "disabled", @readonly = "readonly" })
and
@Html.TextBoxFor(u => u.Visibilidade, new { disabled = "disabled" })
ie. using or…

Felipe Athayde
- 397
- 1
- 4
- 8
30
votes
6 answers
How to set value in @Html.TextBoxFor in Razor syntax?
I have created an text-box using Razor and trying to set value as follows.
@Html.TextBoxFor(model => model.Destination, new { id = "txtPlace", value= "3" })
I have tried appending value with @
@Html.TextBoxFor(model=> model.Destination, new { id =…

viki
- 1,178
- 1
- 17
- 22
24
votes
1 answer
MVC Html.TextBoxFor MaxLength and Value
I am trying to setup a TextBox control in my project using Html.TextBoxFor.
However, it only seems to have method signatures for either:
Lambda Expression and Value:
<%= Html.TextBoxFor(t => t.ProjectDetails.Title,…

Baxter
- 5,633
- 24
- 69
- 105
8
votes
3 answers
TextBoxFor @Value (uppercase) instead @value
This is just for curiosity
Why does this code work:
Html.TextBoxFor(x => x.Age, new { @Value = "0"})
and this doesn't:
Html.TextBoxFor(x => x.Age, new { @value = "0"})
Note the uppercase 'V' in @Value
I know value is a keyword, but so is readonly…

Diego
- 16,436
- 26
- 84
- 136
6
votes
4 answers
MVC2: Impossible to change the name with TextBoxFor?
I want to manually define id and name for textbox like that:
<%: Html.TextBoxFor(model => model.Name, new { @id = "txt1", @name = "txt1" })%>
But only the id is changed, not the name attribute, why?

Tuizi
- 1,643
- 4
- 22
- 34
5
votes
5 answers
How can limit to 2 decimals in TextBoxFor in MVC?
I want after decimal point only 2 digit.
@Html.TextBoxFor(m => m.Viewers, new { @tabindex = 7 })
Need output like this:
56.23
456.20
1.21
like that..

lashja
- 493
- 10
- 21
5
votes
2 answers
Problems using TextBoxFor with viewModels in MVC
I recently started to use a viewModel. Here's the viewModel I am using:
public class ContentViewModel
{
public Content Content { get; set; }
public bool UseRowKey {
get {
return…

Alan2
- 23,493
- 79
- 256
- 450
4
votes
3 answers
Hiding the default value for a date
My View Model:
public partial class FileTransferFilterCriteriaViewModel
{
public string Fice { get; set; }
public string SourceEmail { get; set; }
public string TargetEmail { get; set; }
public DateTime FromDate { get; set; }
…

learning...
- 3,104
- 10
- 58
- 96
3
votes
1 answer
TextBoxFor show date without time
I want to show date in text field in format MM/dd/yy. I described model class as:
public class VacancyFormViewModel
{
public int? ID { get; set; }
[DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:MM/dd/yy}")]
public…

Oleg Sh
- 8,496
- 17
- 89
- 159
3
votes
1 answer
Bold a Certain word in an HTML Textbox
I am creating a report using Telerik reporting tool and I need to bold some specific words in the HTML Textbox.
for instance, my textbox contains this text: "I am Kim and I am a girl". and I only want to Bold the word "I", so it will come out as "I…

Kim
- 771
- 6
- 23
3
votes
2 answers
how to set default value HTML.TextBoxFor()
I have a view consisting of a form and textboxes.
How can I set a default value in each box for strings and int values?
I want the page to load up each box's value so I don't need to type values.
I'm not able to change anything in the Model.
@model…

Fadi Alkadi
- 781
- 4
- 12
- 22
3
votes
3 answers
MVC3 Set Default value for Textbox from model
I have a text box created using
@Html.TextBoxFor(m => m.Model1.field1, new { @class = "login-input", @name="Name", @Value = "test" })
I want to change the default value of this textbox from "text" to a value stored in a model field. How do i set…

jpo
- 3,959
- 20
- 59
- 102
2
votes
2 answers
Textbox data from Javascript
Need a small help.
The below script picks the value from the textbox and add it to the URL.
Example:
Text Box value:
one
two
three
Four
Five
Six
Seven
Output URL:
https://www.google.com/search?q=one+two+three+four+five+six+seven
The help I…

Mathew
- 23
- 4
2
votes
2 answers
To make Textbox write able only after click of Edit button in same View
I have three Textbox which will be in readonly mode like
@Html.TextBoxFor(m => m.Whatever, new {@readonly = "readonly"}) when the view will be loaded and one Edit Button. After click on Edit button i want that Textbox to be writeable in same…

Steve
- 352
- 2
- 6
- 24
2
votes
1 answer
@Html.TextBoxFor Validation
I have a requirement like @Html.TextBoxFor to show the currency in a comma seperated format, without accepting negative values and without special characters. At the same time when the currency is not available, I'm changing the value of this…

Sandy
- 2,429
- 7
- 33
- 63