I have a css class defined to be used in all TEXTBOXEs and TEXTEAREAs. The class is this:
.tboxadd1{
font-family:"Comic Sans MS";
font-size:20px;
color:#D8D8D8;
}
In my VIEW i have the fll: that calls this css style:
@Html.TextBoxFor(m => m.projectType, new { @class = "tboxadd1" })
@Html.TextAreaFor(m => m.projectDescription, 10, 100, new { @class = "tboxadd1"})
The TextArea works fine with the css class, but the TextBox does not work properly. The font-size and color does not work, however the font-family does work on both.
Is there any way of making the font properties work on the TEXTBOXFOR. I dont understand why it shoudlnt work when it works for the TextAreaFor.
ngokal
Member
132 Points
221 Posts
TEXTBOXFOR not picking up FONT SIZE from CSS class
Mar 16, 2012 10:48 AM|LINK
Hi,
I have a css class defined to be used in all TEXTBOXEs and TEXTEAREAs. The class is this:
.tboxadd1{ font-family:"Comic Sans MS"; font-size:20px; color:#D8D8D8; }@Html.TextBoxFor(m => m.projectType, new { @class = "tboxadd1" }) @Html.TextAreaFor(m => m.projectDescription, 10, 100, new { @class = "tboxadd1"})ignatandrei
All-Star
134491 Points
21566 Posts
Moderator
MVP
Re: TEXTBOXFOR not picking up FONT SIZE from CSS class
Mar 16, 2012 10:56 AM|LINK
what's the generated html?
how did yoy registered the css ( inline in the page, in a css file)?
raduenuca
All-Star
24675 Points
4250 Posts
Re: TEXTBOXFOR not picking up FONT SIZE from CSS class
Mar 16, 2012 10:57 AM|LINK
Maybe you should change the size of the textbox as well.
Radu Enuca | Blog
ngokal
Member
132 Points
221 Posts
Re: TEXTBOXFOR not picking up FONT SIZE from CSS class
Mar 16, 2012 11:14 AM|LINK
Its in a CSS file. I have placed it in the Site.css standard css file that comes with MVC3
Ok the the HTML generated code does not have the variables for color, etc .. How come ?
<table class="tableadd"> <tr> <th class="thadd"> <label for="projectName">Project Name</label> </th> <td> <input class="tboxadd1" id="projectName" name="projectName" type="text" value="" /> </td> </tr> <tr> <th class="thadd"> <label for="projectType">Project Type</label> </th> <td> <input class="tboxadd1" id="projectType" name="projectType" type="text" value="" /> </td> </tr> <tr> <th class="thadd"> <label for="projectDescription">Detail Requirement</label> </th> <td> <textarea class="tboxadd1" cols="100" id="projectDescription" name="projectDescription" rows="10"> </textarea> </td> </tr>ignatandrei
All-Star
134491 Points
21566 Posts
Moderator
MVP
Re: TEXTBOXFOR not picking up FONT SIZE from CSS class
Mar 16, 2012 11:19 AM|LINK
Where is
ngokal
Member
132 Points
221 Posts
Re: TEXTBOXFOR not picking up FONT SIZE from CSS class
Mar 16, 2012 11:23 AM|LINK
Hi Radu,
I just changed the height as well, but no luck :-(
ngokal
Member
132 Points
221 Posts
Re: TEXTBOXFOR not picking up FONT SIZE from CSS class
Mar 16, 2012 11:25 AM|LINK
Its in Site.css which is called from _Layout.cshtml :
<link href="@Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" />/************************* CSS CLASS FOR TBOX *************************************/ .tboxadd1{ font-family:"Verdana"; font-size:20px; color:#000000; }ignatandrei
All-Star
134491 Points
21566 Posts
Moderator
MVP
Re: TEXTBOXFOR not picking up FONT SIZE from CSS class
Mar 16, 2012 11:52 AM|LINK
please put
@Html.Raw(string.Format("<link href='{0}' type='text/css' rel='stylesheet' />", ResolveUrl("~/Content/Site.css")))
http://bit.ly/asp5Mistakes
ngokal
Member
132 Points
221 Posts
Re: TEXTBOXFOR not picking up FONT SIZE from CSS class
Mar 16, 2012 12:14 PM|LINK
Hi,
I copied and pasted your code as is, together and also tried without my original (link href above) but i get a error on the "ResolveUrl" word.
I also took out the word "ResolveUrl", and it doesnt work
ignatandrei
All-Star
134491 Points
21566 Posts
Moderator
MVP
Re: TEXTBOXFOR not picking up FONT SIZE from CSS class
Mar 16, 2012 12:20 PM|LINK
Sorry
Put Url.Content