0

I have a Gridview one of it's columns ItemStyle has a css class named xyz i want to change css class to xyzie if the browser is IE , how can i do that ?

example code :

 <asp:GridView ID="GridView1" runat="server" 
    AutoGenerateColumns="False" DataKeyNames="y" 
    DataSourceID="SqlDataSource1" GridLines="None" ShowHeader="False" 
    onselectedindexchanged="GridView1_SelectedIndexChanged" 
    AllowSorting="True" CellSpacing="5" 
    onrowdatabound="GridView1_RowDataBound">
<Columns>
    <asp:BoundField DataField="x" HeaderText="x" SortExpression="x" >
    <ItemStyle CssClass="xyz" /> // want to change this to xyzie if the browser is ie
    </asp:BoundField>
 </Columns>
</asp:GridView>

3 Answers 3

1

If you want to do it server-side then you can use HttpBrowserCapabilities object.

HOWTO article.

Sign up to request clarification or add additional context in comments.

Comments

1

You can use the IE specific conditional comments.

This will allow you to add IE specific classes:

<!--[if IE ]>  
  <body class="ie">  
<![endif]-->  
<!--[if !IE]>-->  
  <body>  
<!--<![endif]-->  

In your CSS you would have an ie class with specific overriding behavior.

6 Comments

@Oded i've tried that already but it doesn't work between <asp:xxx></asp:xxx> tags.
@Oded: You've mentioned (right) in the beginning that conditional comments are IE-specific. By using your example code non-IE users will end up getting two BODY tags.
@dnn - If you post your code, it helps people understand the exact issue. In the future, always post the relevant code. Please edit your question and add your code. The answer from @volpav is probably what you need.
@volpav - I suggest you reread the example. Non IE browsers will only get the second body tag, as the first one is commented out.
@Oded: Sorry, didn't see that the first BODY tag is actually a part of the HTML comment.
|
1

Once you figure out the type of browser, you can dyanmically change CSS. My answer for this post might be of some help

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.