Pages

Setting culture at page and codebehind

 

Setting culture with C#
protected override void InitializeCulture()
{
if (Request.Form["DropDownList1"] != null)
{
// Define the language
UICulture = Request.Form["DropDownList1"];
// Define the formatting (requires a specific culture)
Culture = Request.Form("DropDownList1");
}
base.InitializeCulture();
}

Also if you want to do this setting from page without dont write anything in c# code you can just write this top of the page
<%@ Page UICulture="es" Culture="es-MX" %>

Create Dynamic Master Page


if you want create your dynamic masterpage in your website you can just use this kind of codepart at your code.

Session["masterpage"] = "Master2.master";
Response.Redirect(Request.Url.ToString());

void Page_PreInit(Object sender, EventArgs e)
{
if (Session["masterpage"] != null)
MasterPageFile = (String)Session["masterpage"];
}

Using the XPathNavigator to Search XPathDocuments

protected void Button8_Click(object sender, EventArgs e)
{
lbl = GetLabel(275, 20);
string s;
XPathDocument xmlDoc = new XPathDocument(MapPath("iboxml.xml"));
XPathNavigator nav = xmlDoc.CreateNavigator();
string expr = "//myChild[@ChildID='ref-3']";
//Display the selection
XPathNodeIterator iterator = nav.Select(expr);
XPathNavigator navResult = iterator.Current;
while (iterator.MoveNext())
{
s = String.Format("<b>Type:</b>{0} <b>Name:</b>{1} ",navResult.NodeType, navResult.Name);
if (navResult.HasAttributes)
{
navResult.MoveToFirstAttribute();
s += "<b>Attr:</b> ";
do
{
s += String.Format("{0}={1} ",navResult.Name, navResult.Value);
}
while (navResult.MoveToNextAttribute());
}
lbl.Text += s + "<br>";
}
}