Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6532627
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:01:41+00:00 2026-05-25T10:01:41+00:00

In our project we are using TextBoxFor in many places. We would like to

  • 0

In our project we are using TextBoxFor in many places.
We would like to set the height and width of the TextBoxFor wherever we have used, for that we have done this.

<%= Html.TextBoxFor(x => x, new { @class = "TextBoxFor" } ) %>  


.TextBoxFor
{
    height:30px;
    width:250px; 
    font-family:@Batang;   
    font-size:20px; 
    font-weight: bold;
}

Is it possible to to put the <%= Html.TextBoxFor("", new { @class = "TextBoxFor" } ) %> somewhere in a EditorTemplate / DisplayTemplate and in other places we just call like this

<%= Html.TextBoxFor(x => x) %> 

Which means we are not specifying the css class name. So it is easy to maintain.
Any ideas. Thanks

Update, I created a static helper but it is having errors..

public static MvcHtmlString CustomTextBoxFor<TModel, TProperty>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TProperty>> expression, object htmlAttributes) 
{ 
  return htmlHelper.CustomTextBoxFor<TModel, TProperty>(expression, new { @class = "TextBoxFor" }); 

}



<%: Html.CustomTextBoxFor(m => m.Name) %> 

Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T10:01:41+00:00Added an answer on May 25, 2026 at 10:01 am

    Yes, but you can also create your own Html helper, then do Html.MyTextBoxFor(…).

    Check here for examples

    You can download the MVC3Futures file, and it includes Templatized versions of the default templates, which you can put in your folder. You can edit these to customize the TextBoxFor used. However, you must use @Html.EditorFor(...) in your view rather than TextBoxFor(). Be aware, this will affect all uses of EditorFor in the scope where the templates are installed.

    By the way, if you’re using MVC3, I strongly suggest using the Razor engine rather than the WinForms engine. It’s less typing, and it’s more efficient, and it has features you’re not going to get in WinForms.. and it discourages WinForms thinking.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We're using Mono.Cecil in our project. Does it have any functionality that allows me
We have been using Spring Remoting in our project for sometime. It is used
In our project, we're using gtkmm and we have several classes that extend Gtk::Window
Our issue is that our project has files being downloaded using wget to the
We are using jQuery in our project. We have numerous custom javascript files in
We are currently using unit tests to test our project. We have the majority
We have our project build using maven. We try to run our unit test
Our project is using many static libraries to build the application. How can we
In our project we are using ValidationEngine, and we don't have the ability to
Ok so in our project I'm using System.Linq.Dynamic library but I just noticed that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.