Change background of DateField via code behind

  1. #1

    Change background of DateField via code behind

    Hello, I have a problem changing the background of a DateField (the DateFieldTo in the aspx code) in the codebehind...

    This is my aspx code:
            <ext:FieldContainer ID="FieldContainer2" runat="server" FieldLabel='Validity Period' Split="true" Layout="ColumnLayout">
    		<Items>
                <ext:DateField runat="server" ID="DateFieldFrom" 
                    ColumnWidth=".5" MinWidth="100" Vtype="daterange"
                    PaddingSpec="0 3 0 0" Name="ValidFrom" AllowBlank="false">
                    <CustomConfig>
                        <ext:ConfigItem Name="endDateField" Value="DateFieldTo" Mode="Value" />
                    </CustomConfig>
    			</ext:DateField>
    			<ext:Label ID="Label2" runat="server" Text='-' />
    
                             <%--This is the DateField that I want to change the background--%>
    			<ext:DateField runat="server" ID="DateFieldTo" 
                    ColumnWidth=".5" MinWidth="100" Vtype="daterange"
                    PaddingSpec="0 0 0 3" Name="ValidTo" AllowBlank="true">
                    <CustomConfig>
                        <ext:ConfigItem Name="startDateField" Value="DateFieldFrom" Mode="Value" />
                        </CustomConfig>
    			</ext:DateField>
    		</Items>
    	</ext:FieldContainer>
    this is what the code generates:
    Click image for larger version. 

Name:	9961807927fed3def82b918f7ff09065.png 
Views:	37 
Size:	1.9 KB 
ID:	24478

    and this is what I want to achieve:
    Click image for larger version. 

Name:	e9a5cb7159046392be9a928095abc04b.png 
Views:	30 
Size:	2.4 KB 
ID:	24479

    I've tried:

    DateFieldTo.SetFieldStyle("background-color: rgb(255, 243, 199) !important;");
    but it doesn't work in Chrome and Firefox, am I doing something wrong?
  2. #2
    Hello @RandProgrammer, and welcome to Ext.NET forums!

    Remove from the field style the image-repeat it has there.

    DateFieldTo.SetFieldStyle("background-color:yellow; background-image: none;");
    I hope this helps!
    Fabrício Murta
    Developer & Support Expert
  3. #3
    I can't believe it was just only that!

    Thanks a lot, it worked! :)

Similar Threads

  1. [CLOSED] How to change the background color based on theme change
    By speedstepmem4 in forum 3.x Legacy Premium Help
    Replies: 3
    Last Post: Mar 16, 2015, 2:02 PM
  2. [CLOSED] Stop Change event of DateField on set value to DateField
    By iansriley in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: Apr 24, 2014, 9:05 AM
  3. [CLOSED] V2.0 DateField background
    By Aurelio in forum 2.x Legacy Premium Help
    Replies: 4
    Last Post: Jan 16, 2012, 9:58 AM
  4. Replies: 12
    Last Post: Jun 17, 2009, 12:07 PM
  5. Change Tab background color or background image
    By georgelanes in forum 1.x Help
    Replies: 0
    Last Post: Nov 06, 2008, 3:55 PM

Tags for this Thread

Posting Permissions