Trying to find the best way to dynamically add a direction attribute to each of these html elements. I know how to obtain the direction with
var dir = CultureInfo.CurrentCulture.TextInfo.IsRightToLeft ? "rtl" : "ltr";
but I need to find a graceful way to dynamically add it to the following html
<!--[if lt IE 7]><html class="ie6" lang="en"><![endif]-->;
<!--[if IE 7]><html class="ie7" lang="en"><![endif]-->
<!--[if IE 8]><html class="ie8" lang="en"><![endif]-->
<!--[if gt IE 8]><!--><html lang="en"><!--<![endif]-->
If I put this into a User Control and assign each html element an id, then set each control’s direction attribute, I get runtime errors for not having a closing html tag in the user control.
Is there any simple way for me to set the dir attribute for each of these html elements without doing it through a user control? I’m not even able to place a <asp:Literal> control within each html tag, and it is beginning to frustrate me. Thanks
edit: the end result should be
<!--[if lt IE 7]><html class="ie6" lang="en" dir="ltr"><![endif]-->;
<!--[if IE 7]><html class="ie7" lang="en" dir="ltr"><![endif]-->
<!--[if IE 8]><html class="ie8" lang="en" dir="ltr"><![endif]-->
<!--[if gt IE 8]><!--><html lang="en" dir="ltr"><!--<![endif]-->
You could use the
<asp:Literal>control to output the entire result. You can generate the entire excerpt in code-behind and then feed it to the literal control.Or, you could create a public function:
And call it from within your aspx page: