Reputation: 63
I am trying to apply css class style to my @Html.TextBoxFor control in mvc3 razor view. But I am not able to see the defined style applied to the control. Below is my code:
In my .cshtml file I have the control as:
@Html.TextBoxFor(model => model.project.ProjectName, new { @class = "myStyle"})
In .css file I have defined the style as:
.myStyle
{
width: 150px;
font-family:Arial, Helvetica, sans-serif;
font-size: 1.00em;
}
What am I doing wrong? Can anyone help me please?
Thanks, Balaji
Upvotes: 2
Views: 10923
Reputation: 218922
If you are sure that your style sheet is properly loaded to the page (check the path to style sheet is correct), possible reason for the probelm could be, some other styles are overriding your defined style. Use IMPORTANT
to make this override everything else
input.myStyle
{
width: 150px !IMPORTANT;
font-family:Arial, Helvetica, sans-serif !IMPORTANT;
font-size: 1.00em !IMPORTANT;
}
Upvotes: 2
Reputation: 1031
The .cshtml code looks correct to me. I would inspect the HTML source that gets generated to verify that class="myStyle"
is present on the ProjectName input. If it is present, then the problem lies with your CSS (e.g. another style may be overriding myStyle
).
Upvotes: 0