[C#][2.0] Appel à une fonction dans global.asax
Bonjour,
j'ai rajouté une méthode que je veux commune dans le global.asax.
Ma première question est : Est-ce le bon endroit ?
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| <%@ Application Language="C#" %>
<%@ Import Namespace="System.Globalization" %>
<script runat="server">
String str_GetLanguage()
{
string Lang = Request.UserLanguages[0]; // Principal Language
CultureInfo CurrentCulture = new CultureInfo(Lang);
return (CurrentCulture.Name.Substring(0, 2));
}
void Application_Start(object sender, EventArgs e)
{
// Code that runs on application startup
}
... |
Je ne parviens pas à accèder à cette méthode dans un autre fichier cs.
Que doit on déclarer au début du fichier C# pour atteindre cette fonction.
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
|
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Globalization;
public partial class informations_conditions : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
String str_Lang = str_GetLanguage();
if (!str_Lang.Equals("fr"))
{
str_Lang = "gb";
}
String XmlFile = "../xml/conditions_" + str_Lang + ".xml";
XSL.DocumentSource = XmlFile;
} |