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

adding external stylesheet

2 Answers 187 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Pooja
Top achievements
Rank 1
Pooja asked on 17 Apr 2012, 09:21 PM
Hi,

I have a radgrid whose css is defined in an external stylesheet. I am mainly looking for the height of the radgrid and the width of each of the columns.
The radgrid remains unaffected inspite of the css. I am adding the external style sheet on the server-side in the Page Load like this:
HtmlLink link = new HtmlLink();
                link.Attributes["href"] = "~/Styles/Grids.css";                
                link.Attributes.Add("type", "text/css");
                link.Attributes.Add("rel", "stylesheet");
                Page.Header.Controls.Add(link);

What am I doing wrong?

2 Answers, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 18 Apr 2012, 09:58 AM
Hello pooja,

Please check below code snippet.
 protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

HtmlHead head = (HtmlHead)Page.Header;
           HtmlLink link = new HtmlLink();
           link.Attributes.Add("href", url);
           link.Attributes.Add("type", "text/css");
           link.Attributes.Add("rel", "stylesheet");
           head.Controls.Add(link);
}



Thanks,
Jayesh Goyani
0
Pooja
Top achievements
Rank 1
answered on 18 Apr 2012, 04:44 PM
Hi Jayesh,

Thanks for your reply but it did not work for me.

Just to give you a little more clarity in what I am doing-

This is the HTML for the column width that I am trying to set through the CSS class

<telerik:GridBoundColumn DataField="cta_citi_passenger_name" 
                   HeaderText="Passenger Name" UniqueName="cta_citi_passenger_name" 
                       AllowFiltering="False">
                   <HeaderStyle CssClass="passenger_name" />
                   <ItemStyle CssClass="passenger_name" />
               </telerik:GridBoundColumn>

Now, my CSS class looks like this:

.passenger_name
{
    width:120px;
}

I am using this on a user control (not a page) and referencing the CSS file using the method you mentioned above.

Is there something wrong with what I am doing?
Tags
Grid
Asked by
Pooja
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Pooja
Top achievements
Rank 1
Share this question
or