Programmatically modifying DIR=LTR for Right-To-Left Languages in ASP.NET
Has anyone given any thought on how to programmatically modify/add the dir= attribute to the HTML or BODY tags when the Thread's Culture in ASP.NET is a Right To Left language?
This doesn't work reliablity, as ASP.NET may batch up controls into an HtmlLiteralControl...often, not always, the body (or html) tag can't be found. This depends on how ASP.NET decided to parse the control tree for a particular page. Additionally, there doesn't seem to be anything in CultureInfo that would help me decide what languages are right to left...
If I can reliably get ahold of the HTML control and BODY tags and add this attribute, I'm good.
/* Doesn't work reliably */
HtmlGenericControl bodytag = (HtmlGenericControl)FindControl("body");
bodytag.Attributes["dir"] = "rtl";
else
bodytag.Attributes["dir"] = "rtl";
About Scott
Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.
About Newsletter
Comments are closed.