Hi Paul,
Thanks for your reply. It is correct i am using c#.
The error message is same as it was before. I am doing it as you were
suggesting but I think it doesn't like the keyword Static???
What are the other ways to access this textbox in the header file??? Or
maybe it should be done after PageLoad event? at the
moment I am keeping the code in the page load event of the page as:
public class SpecialOffers : System.Web.UI.P age, IPageToIncludeH eaderFooter
//this is the interface for Header and Footer that i implement
{
protected System.Web.UI.W ebControls.Imag e imgPromotion;
protected System.Web.UI.W ebControls.Labe l lblPromotion;
protected System.Web.UI.W ebControls.Hype rLink hlPromotion;
protected System.Web.UI.W ebControls.Text Box txtHidden;
private void Page_Load(objec t sender, System.EventArg s e)
{
Response.Write( GlobalObject.Fi rstName);
txtHidden.Text= GlobalObject.Fi rstName;
Response.Write( GlobalObject.La stName);
MobileShop.Head er.txtUserName. Text="hello";
}
Compiler Error Message: CS0176: Static member
'MobileShop.Hea der.txtUserName ' cannot be accessed with an instance
reference; qualify it with a type name instead
Source Error:
Line 1: <%@ Control Language="c#" AutoEventWireup ="false"
Codebehind="Hea der.ascx.cs" Inherits="Mobil eShop.Header"
targetSchema="h ttp://schemas.microso ft.com/intellisense/ie5" %>
Line 2: <P style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PAGE-BREAK-BEFORE:
auto; PADDING-BOTTOM: 0px; MARGIN: 0px; PAGE-BREAK-AFTER: auto; CLIP:
rect(0px auto auto 0px); PADDING-TOP: 0px; POSITION: static; TEXT-ALIGN:
left"
Line 3: align="left">
"Paul D McM" <Pa******@discu ssions.microsof t.com> wrote in message
news:C0******** *************** ***********@mic rosoft.com...
G'day Annie.
Presumably you are using c#...
You are probably doing something like this:
this.myheader.T heTextBox.Text = "hello world" ;
Try changing the "this.myhea der" - i.e. referencing the TextBox via the
instance - to something like:
MyProject.heade rControlClass.T extBox.Text = "hello world" ;
i.e. reference it via the Class name, rather than the instance name...
Hth,
Cheers,
Paul
"Annie" wrote:
hello guys,
I have a header file in the form of user control (.ascx) that all my
pages
inherit from it. I have a textbox that i need to access it
from all the pages actually i show there user details there and needs to
update it. So i set this textbox as Public and Static. The
code compiles fine and the textbox is accessable to all pages however i
have
the following compilation errr:
Compiler Error Message: CS0176: Static member
'MobileShop.Hea der.txtClient'
cannot be accessed with an instance reference; qualify it with a type
name
instead
Source Error:
Line 1: <%@ Control Language="c#" AutoEventWireup ="false"
Codebehind="Hea der.ascx.cs" Inherits="Mobil eShop.Header"
targetSchema="h ttp://schemas.microso ft.com/intellisense/ie5" %>
Line 2: <P style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px;
PAGE-BREAK-BEFORE:
auto; PADDING-BOTTOM: 0px; MARGIN: 0px; PAGE-BREAK-AFTER: auto; CLIP:
rect(0px auto auto 0px); PADDING-TOP: 0px; POSITION: static; TEXT-ALIGN:
left"
Line 3: align="left">
Source File: http://localhost/MobileShop/Header.ascx Line: 1
I don't know why this error please help
TIA