473,757 Members | 2,081 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Asp.net Header file scenario please ... (compilation err)

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
Nov 19 '05 #1
2 3698
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

Nov 19 '05 #2
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

Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2227
by: Chris Mantoulidis | last post by:
Seperate compilation (that's what it's called, right?) seems to be quite popular, so I decided to get some info about it, and (d'oh) use it... But it's whole structure seems weird to me... Here's what I think of how it is (from what I've read): THE PROJECT +1st header file
18
2255
by: Exits Funnel | last post by:
Hello, I'm a little confused about where I should include header files and was wondering whether there was some convention. Imagine I've written a class foo and put the definition in foo.h and the implementation of its member functions in foo.cpp (which obviously #inludes foo.h) and further assume that it depends on a class bar which is defined in bar.h. It seems that there are the following two scenarios:
12
12874
by: blueblueblue2005 | last post by:
Hi, here is an example I copied from Deitel C++ book. but when I compile it, always get the above compilation error, no matter how I change the include order, please help. here is the files: Note: this is to practice Proxy classes. // Implementation.h class Implementation {
60
8313
by: Derrick Coetzee | last post by:
It seems like, in every C source file I've ever seen, there has been a very definite include order, as follows: - include system headers - include application headers - include the header associated with this source file For example, in a file hello.c: #include <stdio.h>
1
1729
by: Lauchlan M | last post by:
Hi. I have an ASP.net project that works fine. I copied it to another project using the following steps: << (i) create a new VS.NET ASP.NET project.
5
5859
by: Mikael S. H. | last post by:
Header file compilation I'm coding a small irc bot, and I've noticed that compilation takes very long when I add certain header files (compared to compilation time without). I've tried to find out if it is possible to compile a header file, yet I have only found that it is possible, but not how it is done. I have RTFM, STFW and searched USENET, yet I have only found a document saying "just write `g++ file.h`, and it'll work".
4
6024
by: Madhur | last post by:
I have problems faced in adding definitions in the command header file. I have defined a header file which includes huge set of global constants and I am using them in all the C files. For example my sample.h file looks like this /************* File : sample.h
1
2068
by: jacek.dziedzic | last post by:
Hi! I have a program that #includes a header file of an external library. If the environment is set-up correctly, this file is found in the include path and everything works. Now, assume that a user forgot to either install the external library
8
4593
by: nguillot | last post by:
Hello. If I have the following classes: class B {}; typedef B tB; if A is: class A
0
9487
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9297
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
9884
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9735
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6556
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5168
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5324
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3828
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3395
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.