Questions tagged [html.textbox]

ASP.NET MVC helper to make textboxes

28 questions
40
votes
4 answers

how to set id to Html.TextBox item on MVC

Im trying to catch the textbox element by javascript, in order to put text into it. so how to set id to the textbox ?? // Id to this textbox @Html.TextBoxFor(item => item.OperationNo) …
Fadi Alkadi
  • 781
  • 4
  • 12
  • 22
35
votes
3 answers

Html.TextBoxFor format and css class

The two lines of code below work fine, but I want to combine them. What I mean is: I want to use the @class in the first code line. How can I do that? <%: Html.TextBoxFor(model => model.Product.Price, String.Format("{0:f}",…
Filip
  • 1,098
  • 5
  • 17
  • 34
29
votes
6 answers

MVC3 Conditionally disable Html.TextBoxFor()

I have a C# .Net web app. In that app I need to conditionally disable Html.TextBoxFor controls (also Html.DropDownListFor controls) based on who is logged into the system. I tried using @Html.TextBoxFor(model => model.ProposalName, new {…
MikeTWebb
  • 9,149
  • 25
  • 93
  • 132
13
votes
4 answers

MVC3 & Razor - Change DateTime String from "mm/dd/yyyy 12:00:00 AM" to "mm/dd/yyy" in a Textbox

I am trying to stop the Time from showing up in a Birthday Text Field that uses DateTime My Code: (I'm using the Jquery DatePicker) @Html.TextBox("birthday", (Model.Birthday.ToString()), new {…
Timothy Green
  • 1,851
  • 5
  • 17
  • 22
9
votes
2 answers

Asp.NET MVC Html.TextBox refresh problem

i have a problem with asp.net mvc 2 and the html.textboxfor helper. i use the follow code in a form: <%= Html.TextBoxFor(model => model.Zip, new { @class = "txt", id = "zip", tabindex = 1 })%> when the user send the form, i validate the zipcode,…
martin
  • 93
  • 1
  • 4
4
votes
3 answers

MVC 3 html.TextBoxFor readonly Properties to be set dynamically

<%: Html.LabelFor(Model => Model.Date, "Date")%> <%: Html.TextBoxFor(Model => Model.Date)%> Here i want to set the readonly property…
samdinesh
  • 147
  • 1
  • 3
  • 9
4
votes
1 answer

Html.Display does not work with ViewBag

Html.Display does not work with ViewBag. @Html.Display("disp", (string)@ViewBag.disp) I must use this viewbag because it can be modified by a search button selecting another disp. @Html.TextBox("disp", (string)@ViewBag.disp) If I use TextBox…
arnoldrob
  • 813
  • 3
  • 9
  • 15
3
votes
2 answers

Vs Vs Html.TextBox

I am working in asp.net application, adding functionalities like form elements, validation and populating data from DB. I can use ASP: controls but I am wondering is it possible to use HTML.TextBox or If I can use
Ajax3.14
  • 1,647
  • 5
  • 24
  • 42
2
votes
3 answers

ASP.NET MVC2 -- Trouble with Model Binding and Html.Textbox()

ASP.NET MVC Model Binding is still new to me and I'm trying to understand exactly how it works. Right now, I appear to be having problems with a feature of Html.Textbox() Specifically, I have a View where I set Html.Textbox to a value both in the…
Pretzel
  • 8,141
  • 16
  • 59
  • 84
2
votes
2 answers

Remove text onclick/onfocus event of @Html.TextArea

I am working on an MVC 3 project. In my view I have textboxes and Text area which I am calling using @Html.TextBox/TextArea. Can anyone please tell me, how can I define the onclick or onfocus even of these controls? I am unable to find a syntax for…
haldar55
  • 59
  • 1
  • 1
  • 11
1
vote
1 answer

Html.TextBoxFor change color value if error at login

I am new to mvc and I wonder how I can change the background color if the User do@html.TextBoxFor enter the wrong login. I'm using it quite simply. @Html.TextBoxFor(m => m.Email, new {@class="caixa_login_email" }) How could add a new value for…
1
vote
1 answer

MVC5 dynamically disable textbox based on another textbox value

I have MVC5 project and have 2 text box's fields(client id, document id) and one drop-down list. I would like dynamically enable or disable client id text box and drop down list based on document id value, for example, if I wrote something in…
So_oP
  • 1,211
  • 15
  • 31
1
vote
1 answer

MVC 2 - Name Attributes on HTML Input Field when using Parent/Child Entities

I'm pretty new to MVC 2 using the Entity Framework. I have two tables Company {ID int identity PK,Name nvarchar} and User {ID int identity PK,UserName nvarchar,CompanyID int FK}. A Foreign Key exists between User and Company. I generated my ADO.NET…
1
vote
4 answers

How to override CSS for TextBoxFor field?

Have the following class in Site.css: input[type="textbox"].TextBoxAsLabel { background:#f2f3f3 !IMPORTANT; } want to override default background for TextBoxFor field in Edit.cshtml @Html.TextBoxFor(model => model.ClientNumber, new {@readonly…
user2911759
  • 61
  • 2
  • 10
1
vote
3 answers

asp.net mvc How to display default value on a date type textbox

I'm developing in asp.net mvc. I want to have a textbox which is date type, so there's a shortcut that user can click and select a date instead of type in. Meanwhile I want the textbox to display a default date value. I have tried 2 ways:
user2093360
  • 249
  • 3
  • 4
  • 8
1
2