This is a migrated thread and some comments may be shown as answers.

Overriding Radwindow default styles in code behind

1 Answer 183 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Jesse
Top achievements
Rank 1
Jesse asked on 30 Mar 2020, 08:52 PM

Hi is there  away to override radwindow default styles in the code behind for example

 

 

    .RadWindow .rwStatusbar,
    .RadWindow_Default table .rwTopLeft,
    .RadWindow_Default table .rwTopRight,
    .RadWindow_Default table .rwFooterCenter,
    .RadWindow_Default table .rwFooterLeft,
    .RadWindow_Default table .rwFooterRight,
    .RadWindow_Default .rwCorner,
    .RadWindow_Default .rwBodyLeft,
    .RadWindow_Default .rwBodyRight {
        display: none !important;
    }

 

using something like this

window.class[.RadWindow .rwStatusbar]. add.style( "display", "none")

window.class[. .RadWindow_Default table .rwTopLeft,]. add.style( "display", "none")

 

...

 

 

Thanks in advance.

 

1 Answer, 1 is accepted

Sort by
0
Attila Antal
Telerik team
answered on 02 Apr 2020, 10:44 AM

Hi Jesse,

Telerik controls render an entire hierarchy in the DOM elements, for example:

<div class="RadWindow">
    <div class="someClass">
        <div class="someOtherClass">
            <span class="someLabel">
            </span>
        </div>
        <div>
            <span class="someotherLabel">
            </span>
        </div>
    </div>
</div>

 

Yet, the RadWindow object in the Code Behind only provides style properties to a few. You can change its style in the following way the RadWindow1.Style.Add("width", "300px");. This will add a style attribute to the outermost element:

protected void Page_Load(object sender, EventArgs e)
{
    var RadWindow1 = new RadWindow();

    RadWindow1.Style.Add("width", "300px");
}

 

Results will be

<div class="RadWindow" style="width: 300p;x">
    <div class="someClass">
        <div class="someOtherClass">
            <span class="someLabel">
            </span>
        </div>
        <div>
            <span class="someotherLabel">
            </span>
        </div>
    </div>
</div>

 

The rest of the elements rendered within the Window cannot be accessed. The CSS styles, on the other hand, are styling the main element and also its child elements. If you want to override them, you'll need to change the CSS style. 

Furthermore, applications today use less and less logic in the server or client and utilize CSS as much it is possible to improve performance. Changing styles on the server will add additional work for the WebServer and degrading its performance.

Another option would be to create your own CSS stylesheet that will target the RadWindow and load that on the server following the instructions from the Add css class from code behind using literal control StackOverflow article.

I hope this will prove helpful.

Kind regards,
Attila Antal
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
Tags
General Discussions
Asked by
Jesse
Top achievements
Rank 1
Answers by
Attila Antal
Telerik team
Share this question
or