Possible Duplicate:
How to add namespaces in web.config file?
I am trying to add namespace in web.config file, so that I can use it in all web pages (in code behind). But it is not working.
Has anybody tried it ? I have asked this before but not get any suitable answer.
To better understand here is code behind file
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace TestWeb
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Label1.BackColor = Color.Red;// It is not working.
}
}
}
This is web.config file
<?xml version="1.0"?>
<configuration>
<system.web>
<pages>
<namespaces>
<clear/>
<add namespace="System.Drawing" />
</namespaces>
</pages>
</system.web>
</configuration>
Edit
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="TestWeb._Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
void Page_Load(object sender, EventArgs e)
{
Label1.BackColor = Color.Red;
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:label ID="Label1" runat="server" text="Label"></asp:label>
</div>
</form>
</body>
</html>