Bonjour à tous.
Je cherche à modifier un attribut (ou à en ajouter un) au body de ma masterpage pour l'internationalisation de mon application.
Mon application est disponible en hébreux, ce qui signifie qu'il faut que la page soit lisible de droite à gauche. Pour cela, il y a l'attribut dir dans la balise body.
Je souhaite pouvoir intervenir sur cet attribut par le code behind en utilisant ce code trouver dans la FAQ :
Code:<body id="body" runat="server">
Mais il me ressort une erreur :Code:
1
2
3
4
5
6
7
8
9 string Lang = Request.UserLanguages[0]; // Principal Language CultureInfo CurrentCulture = new CultureInfo(Lang); HtmlGenericControl _body = (HtmlGenericControl)Page.FindControl("body"); if (CurrentCulture.Name.Substring(0, 2).ToUpper().Equals("HE")) { _body.Attributes.Add("dir", "rtl"); }
Quelqu'un aurait-il une piste ?Citation:
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
Line 27: if (CurrentCulture.Name.Substring(0, 2).ToUpper().Equals("HE"))
Line 28: {
Line 29: _body.Attributes.Add("dir", "rtl");
Line 30: }
Line 31: }
Merci d'avance.