473,811 Members | 2,971 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to make a button static?

hello i'm doing this

protected static System.Web.UI.W ebControls.Butt on btnExcel;

hoping that it would remain shared but when i run the application i get this
error

Compiler Error Message: CS0176: Static member 'NPI.Search.btn Excel' cannot
be accessed with an instance reference; qualify it with a type name instead

any other how i can over come this problem?

Nov 19 '05 #1
5 2182
On Mon, 31 Jan 2005 19:43:02 -0800, =?Utf-8?B?QXNoYQ==?=
<As**@discussio ns.microsoft.co m> wrote:
hello i'm doing this

protected static System.Web.UI.W ebControls.Butt on btnExcel;

hoping that it would remain shared but when i run the application i get
this
error

Compiler Error Message: CS0176: Static member 'NPI.Search.btn Excel'
cannot
be accessed with an instance reference; qualify it with a type name
instead

any other how i can over come this problem?


If you look in the InitializeCompo nent method you'll notice it is pry
being accessed by the auto-generated code like this:

btnExcel.Text = "Excel";

since it's really an object (instance of a class). I'm not sure why
you're trying to do this, but if you changed the 'protected static'
portion to just 'public' is that good enough?

--
Craig Deelsnyder
Microsoft MVP - ASP/ASP.NET
Nov 19 '05 #2
I don't think it makes much sence. Web controls always live on pages.
Therefore you have to have a page instance reference to acces them. When you
write btnExcel it actually means this.btnExcel, where "this" is a reference
to the page.

Eliyahu

"Asha" <As**@discussio ns.microsoft.co m> wrote in message
news:3B******** *************** ***********@mic rosoft.com...
hello i'm doing this

protected static System.Web.UI.W ebControls.Butt on btnExcel;

hoping that it would remain shared but when i run the application i get this error

Compiler Error Message: CS0176: Static member 'NPI.Search.btn Excel' cannot
be accessed with an instance reference; qualify it with a type name instead
any other how i can over come this problem?

Nov 19 '05 #3
Won't work anyway IMO. The page just lives the time of the HTTP request. Why
would a button on this page live longer ?

You may want to tell us what you are trying to do...

Patrice

--

"Asha" <As**@discussio ns.microsoft.co m> a écrit dans le message de
news:3B******** *************** ***********@mic rosoft.com...
hello i'm doing this

protected static System.Web.UI.W ebControls.Butt on btnExcel;

hoping that it would remain shared but when i run the application i get this error

Compiler Error Message: CS0176: Static member 'NPI.Search.btn Excel' cannot
be accessed with an instance reference; qualify it with a type name instead
any other how i can over come this problem?

Nov 19 '05 #4
Don't make it static.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.

"Asha" <As**@discussio ns.microsoft.co m> wrote in message
news:3B******** *************** ***********@mic rosoft.com...
hello i'm doing this

protected static System.Web.UI.W ebControls.Butt on btnExcel;

hoping that it would remain shared but when i run the application i get
this
error

Compiler Error Message: CS0176: Static member 'NPI.Search.btn Excel' cannot
be accessed with an instance reference; qualify it with a type name
instead

any other how i can over come this problem?

Nov 19 '05 #5
while it makes no sense to make the button static (and would prevent two
copies of the page running at the same time correctly), just replace all
references to 'btnExcel' with 'NPI.Search.btn Excel'.

'btnExcel' is a shortcut for 'this.btnExcel' . because 'btnExcel' is a
static, the default reference doesn't work.
-- bruce (sqlwork.com)

"Asha" <As**@discussio ns.microsoft.co m> wrote in message
news:3B******** *************** ***********@mic rosoft.com...
| hello i'm doing this
|
| protected static System.Web.UI.W ebControls.Butt on btnExcel;
|
| hoping that it would remain shared but when i run the application i get
this
| error
|
| Compiler Error Message: CS0176: Static member 'NPI.Search.btn Excel' cannot
| be accessed with an instance reference; qualify it with a type name
instead
|
| any other how i can over come this problem?
|
Nov 19 '05 #6

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

Similar topics

9
66530
by: Ray Muforosky | last post by:
Hello, Is there a way to render a text or button tag without a sunken or raised surface respectively. Ray
9
2827
by: Rajat Tandon | last post by:
Hello there, I am relatively new to the newsgroups and C#. I have never been disappointed with the groups and always got the prompt replies to my queries.This is yet another strange issue, I am facing. Please please help me to solve this as soon as possible. So here we go ... I am not able to take the screen shot of the windows form based "Smart
6
5128
by: divya | last post by:
I have a page name edit.asp which should expire immediately .The user cannot open this page directly he has to provide a password for entering this page.thus when the user enters edit.asp , it has a button EDIT ,which when user clicks directs him to another page (done.asp). Now the problem is that from this page (done.asp) if he clicks on the back button on the toolbar then edit.asp opens.But I don't want it to open It should show page...
2
11967
by: Danny | last post by:
Hi I want to be able from my csharp button to start an application ( which I can do) and then somehow send a message to the win32 application that says "press the button" The win32 application ( borland app) has a button on it that I need to click in order for it to start correctly. Is this possible from csharp?? thanks
0
951
by: jeff.sharkfinn | last post by:
I'm trying to create a pointer to a class in form1.h button1 event handler. It should be simple... but no. This example is as simple as I can make: Form1.h (produced with the designer containing a single button) *********************************************************************************** #pragma once namespace MyProject {
18
2630
by: bning | last post by:
Hmm this forum really doesn't give you long enough to type in your question before logging you out.. well here goes my second attempt: I'm trying to teach myself javascript with dom scripting and am attempting to write an application as I learn. It's been going fine but I've ran into a problem which is driving me crazy. I'll start off by explaining what I'm trying to achieve... I'm simply trying to insert an input button into a table at a...
3
1842
by: shimajavar | last post by:
Hi all I have the following code: a line is growing up by clicking on "up" button, it has another button"start" which I want it to stop the process of growing the line...How can I make a button to stop the process of another button? class Program: Form { int x1; int y1; int x2;
7
6948
by: ITAutobot25 | last post by:
My delete button is not working in my GUI and my due date is today before midnight. Can anyone show me how to correct this error? My assignment statement is below as well as 5 classes. InventoryGUI is the main class to begin execution. Thanks! • Modify the Inventory Program to include an Add button, a Delete button, and a Modify button on the GUI. These buttons should allow the user to perform the corresponding actions on the item name, the...
2
2817
by: chrisp | last post by:
I have an ASP.NET 2 page with a button that causes a credit card transaction to be authorised. The authorisation procedure may take a few seconds and so I want to prevent the user from clicking the button again (or at least detect that an authorisation is already in progress and do nothing) while the first authorisation is in progress. Can someone help me out? I've tried the following but none of the solutions work: 1) Disabling the...
0
9728
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
9605
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,...
0
10389
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9205
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7670
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5554
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
5692
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4339
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
2
3867
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.