Click here to Skip to main content
15,892,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am working on font of regular expression.,,,from code behind to 11px.... ,, how could i do that, it is looking like
RFvalidatorname.Font but it required field validator working on small, extra small large etc.


i also did
aspx :
XML
<style type="text/css">
.err {font-size: 11px;}

</style>


Code behind:

C#
rgvresetpassduration.ErrorMessage = "Enter password change duration";
rgvresetpassduration.Font.Name = "Tahoma";
rfvLockoutDuration.Font.Name = "Tahoma";
rfvLockoutDuration.ErrorMessage = "Enter lock-out duration";

rfvLockoutDuration.CssClass = "err";
rgvresetpassduration.CssClass = "err";


but not get the font size 11px
Posted
Comments
Sergey Alexandrovich Kryukov 1-Apr-13 11:40am    
Why not putting all the form information in CSS only? If you setting the font in code behind (why?) why not setting the size as well?
—SA
Ali_100 1-Apr-13 11:48am    
it is not getting the font size & font family,,, i am using devexpress,,, while i use the facility of code behind it is working but not for font size.. so i am very desperate to know that.

There are many ways to do this..

1. Use Font-Size attribute
HTML
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="Name cann't be blank" ControlToValidate="TextBox1" Font-Size="Small"></asp:RequiredFieldValidator>

or
HTML
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="Name cann't be blank" ControlToValidate="TextBox1" Font-Size="11px"></asp:RequiredFieldValidator>

2. Use style property
XML
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="Name cann't be blank" ControlToValidate="TextBox1" style="font-size:11px;"></asp:RequiredFieldValidator>


3. Through code behind.
C#
protected void Page_Load(object sender, EventArgs e)
    {
        if (!this.IsPostBack)
        {
            //RequiredFieldValidator1.Style.Add("font-size", "11px");
            //or
            RequiredFieldValidator1.CssClass = "err";
        }
    }

I think you missed to write your code in PageLoad event. check again.. hope this will help you..
 
Share this answer
 
Comments
Ali_100 2-Apr-13 3:47am    
No well I did it by.

rfv.Font.Size = new System.Web.UI.WebControls.FontUnit("11px");

---------------------------------------------------------------

I can 't able to understand why the other could not work, I am amazed what i used & after your suggestion too,well i did it this is gratitute
vinodkumarnie 2-Apr-13 4:19am    
Ok. Thats fine. Did you tried the above solution..? Which is easy..
rfv.Font.Size = new System.Web.UI.WebControls.FontUnit("11px");
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900