I'm using C# as code-behind for my aspx pages. How can I bind pages..
so that both the pages can use the functions, variables, controls .. between
each other.
eg., if I declare function scope() in page1, I should be able to use it in
page2 and vice-versa. same with variable also..
Any help would be grealty apprecited!
Thanks
Steven 5 1290
Steven wrote: I'm using C# as code-behind for my aspx pages. How can I bind pages.. so that both the pages can use the functions, variables, controls .. between each other.
eg., if I declare function scope() in page1, I should be able to use it in page2 and vice-versa. same with variable also..
Any help would be grealty apprecited!
Thanks Steven
Create one .aspx.cs classfile and then change the Inherits attribute
value on the Page directive as appropriate: http://www.aspsmith.com/viewarticle...._article_id=42
If using VS.NET, note it normally creates a different code-behind file
for each .aspx, but there's no reason you can't change that attribute to
point at a different (shared) .aspx.cs
--
Craig Deelsnyder
Microsoft MVP - ASP/ASP.NET
I have 2 pages (mainform.aspx and print.aspx). As in your article I chaged
the code-behind for print.aspx to mainform.aspx.cs. So theoritically, I
should be able to access the control mainbut (Main button) from my
print.aspx page. But I'm unable to do that. What is wrong in my approach?
please help !
Thanks
Steven
"Craig Deelsnyder" <cdeelsny@NO_SPAM_4_MEyahoo.com> wrote in message
news:uP****************@TK2MSFTNGP09.phx.gbl... Steven wrote: I'm using C# as code-behind for my aspx pages. How can I bind pages.. so that both the pages can use the functions, variables, controls .. between each other.
eg., if I declare function scope() in page1, I should be able to use it in page2 and vice-versa. same with variable also..
Any help would be grealty apprecited!
Thanks Steven Create one .aspx.cs classfile and then change the Inherits attribute value on the Page directive as appropriate:
http://www.aspsmith.com/viewarticle...._article_id=42
If using VS.NET, note it normally creates a different code-behind file for each .aspx, but there's no reason you can't change that attribute to point at a different (shared) .aspx.cs
-- Craig Deelsnyder Microsoft MVP - ASP/ASP.NET
I'm quite new to this stuff so I'm only guessing......
... but if you inherit from the same code begind class doesn't each page get
its' own instance of the button? What you need is to get some kind of
reference/handle to the mainpage from the printpage. So theoritically, I should be able to access the control mainbut (Main button) from my print.aspx page
I don't think so. When you write
mainbut.text = "change, damn your hide!";
you are really writing:
self.mainbut.text = "change, damn your hide!";
which is the same as:
printpage.mainbut.text = "change, damn your hide!";
and if your printpage doesn't have a rendered control called mainbut then
not much will happen.
I'm afraid I can't really see what you want to do. I guess you have a main
page which spawns the print page, and when this finishes printing you want
to disable the print button or something. The thing is I don't understand
how you think both pages will be active at the same time in the app
lifecycle, other than in two (tabs?) browsers.
To get the main page to show any state that recently changed in the print
page then you must somehow trigger a refresh which looks at a common
variable.
I'm intrigued by the problem but I don't have a quick solution.
"Steven" <counterball_20122@_hotmail.com> wrote in message
news:#c**************@TK2MSFTNGP15.phx.gbl... I have 2 pages (mainform.aspx and print.aspx). As in your article I chaged the code-behind for print.aspx to mainform.aspx.cs. So theoritically, I should be able to access the control mainbut (Main button) from my print.aspx page. But I'm unable to do that. What is wrong in my approach?
please help !
Thanks Steven
"Craig Deelsnyder" <cdeelsny@NO_SPAM_4_MEyahoo.com> wrote in message news:uP****************@TK2MSFTNGP09.phx.gbl... Steven wrote: I'm using C# as code-behind for my aspx pages. How can I bind pages.. so that both the pages can use the functions, variables, controls .. between each other.
eg., if I declare function scope() in page1, I should be able to use it in page2 and vice-versa. same with variable also..
Any help would be grealty apprecited!
Thanks Steven Create one .aspx.cs classfile and then change the Inherits attribute
value on the Page directive as appropriate:
http://www.aspsmith.com/viewarticle...._article_id=42
If using VS.NET, note it normally creates a different code-behind file
for each .aspx, but there's no reason you can't change that attribute to
point at a different (shared) .aspx.cs
-- Craig Deelsnyder Microsoft MVP - ASP/ASP.NET
KMA wrote: I'm quite new to this stuff so I'm only guessing......
.. but if you inherit from the same code begind class doesn't each page get its' own instance of the button? What you need is to get some kind of reference/handle to the mainpage from the printpage.
So theoritically, I
should be able to access the control mainbut (Main button) from my print.aspx page
I don't think so. When you write mainbut.text = "change, damn your hide!";
you are really writing: self.mainbut.text = "change, damn your hide!";
which is the same as: printpage.mainbut.text = "change, damn your hide!";
and if your printpage doesn't have a rendered control called mainbut then not much will happen.
I'm afraid I can't really see what you want to do. I guess you have a main page which spawns the print page, and when this finishes printing you want to disable the print button or something. The thing is I don't understand how you think both pages will be active at the same time in the app lifecycle, other than in two (tabs?) browsers.
To get the main page to show any state that recently changed in the print page then you must somehow trigger a refresh which looks at a common variable.
I'm intrigued by the problem but I don't have a quick solution.
"Steven" <counterball_20122@_hotmail.com> wrote in message news:#c**************@TK2MSFTNGP15.phx.gbl...
I have 2 pages (mainform.aspx and print.aspx). As in your article I chaged the code-behind for print.aspx to mainform.aspx.cs. So theoritically, I should be able to access the control mainbut (Main button) from my print.aspx page. But I'm unable to do that. What is wrong in my approach?
please help !
Thanks Steven
"Craig Deelsnyder" <cdeelsny@NO_SPAM_4_MEyahoo.com> wrote in message news:uP****************@TK2MSFTNGP09.phx.gbl.. .
Steven wrote:
I'm using C# as code-behind for my aspx pages. How can I bind pages.. so that both the pages can use the functions, variables, controls .. between each other.
eg., if I declare function scope() in page1, I should be able to use it in page2 and vice-versa. same with variable also..
Any help would be grealty apprecited!
Thanks Steven
Create one .aspx.cs classfile and then change the Inherits attribute value on the Page directive as appropriate:
http://www.aspsmith.com/viewarticle...._article_id=42
If using VS.NET, note it normally creates a different code-behind file for each .aspx, but there's no reason you can't change that attribute to point at a different (shared) .aspx.cs
-- Craig Deelsnyder Microsoft MVP - ASP/ASP.NET
I thought you were referring to sharing the code, not actual instances
of controls/objects. The actual page/control instances are created for
each request. What are you trying to do? Share code, or share actual
runtime objects? Or do something on the client-side (click a button, etc.)?
If you wanted to populate a variable on one page and access it in
another, you should pass it via the querystring, or session, or
cache...many ways to persist values for retrieval on other pages...
--
Craig Deelsnyder
Microsoft MVP - ASP/ASP.NET
Allright, I think I found some solution for this ..
I want access GetURL class (which is declared in mainform.aspx) from
show.aspx.
I declared this in my mainform.aspx.cs on page_load event:
show oshow = new show() ;
oshow.PerformHandShake(this) ;
and in show.aspx, I'm trying to access the class GetURL like:
protected mainform MainFormPointer:
public void PerformHandShake(mainform mainfptr)
{
this.MainFormPointer = mainfptr;
}
private void Page_Load(object sender, System.EventArgs e)
{
String Main = " Show Me";
string post = this.MainFormPointer.GetURL(Main); --> Line 8
}
When I try to run this code, error is popping up saying " Object Reference
not set to an instance of the object" in Line 8. What could be the error?
Thanks
Steven
"Craig Deelsnyder" <cdeelsny@NO_SPAM_4_MEyahoo.com> wrote in message
news:eH*************@TK2MSFTNGP12.phx.gbl... KMA wrote: I'm quite new to this stuff so I'm only guessing......
.. but if you inherit from the same code begind class doesn't each page get its' own instance of the button? What you need is to get some kind of reference/handle to the mainpage from the printpage.
So theoritically, I
should be able to access the control mainbut (Main button) from my print.aspx page
I don't think so. When you write mainbut.text = "change, damn your hide!";
you are really writing: self.mainbut.text = "change, damn your hide!";
which is the same as: printpage.mainbut.text = "change, damn your hide!";
and if your printpage doesn't have a rendered control called mainbut then not much will happen.
I'm afraid I can't really see what you want to do. I guess you have a main page which spawns the print page, and when this finishes printing you want to disable the print button or something. The thing is I don't understand how you think both pages will be active at the same time in the app lifecycle, other than in two (tabs?) browsers.
To get the main page to show any state that recently changed in the print page then you must somehow trigger a refresh which looks at a common variable.
I'm intrigued by the problem but I don't have a quick solution.
"Steven" <counterball_20122@_hotmail.com> wrote in message news:#c**************@TK2MSFTNGP15.phx.gbl...
I have 2 pages (mainform.aspx and print.aspx). As in your article I chaged the code-behind for print.aspx to mainform.aspx.cs. So theoritically, I should be able to access the control mainbut (Main button) from my print.aspx page. But I'm unable to do that. What is wrong in my approach?
please help !
Thanks Steven
"Craig Deelsnyder" <cdeelsny@NO_SPAM_4_MEyahoo.com> wrote in message news:uP****************@TK2MSFTNGP09.phx.gbl. ..
Steven wrote:
>I'm using C# as code-behind for my aspx pages. How can I bind pages.. >so that both the pages can use the functions, variables, controls .. >between each other. > >eg., if I declare function scope() in page1, I should be able to use it >in page2 and vice-versa. same with variable also.. > >Any help would be grealty apprecited! > >Thanks >Steven
Create one .aspx.cs classfile and then change the Inherits attribute
value
on the Page directive as appropriate:
http://www.aspsmith.com/viewarticle...._article_id=42
If using VS.NET, note it normally creates a different code-behind file
for
each .aspx, but there's no reason you can't change that attribute to
point
at a different (shared) .aspx.cs
-- Craig Deelsnyder Microsoft MVP - ASP/ASP.NET
I thought you were referring to sharing the code, not actual instances of controls/objects. The actual page/control instances are created for each request. What are you trying to do? Share code, or share actual runtime objects? Or do something on the client-side (click a button, etc.)?
If you wanted to populate a variable on one page and access it in another, you should pass it via the querystring, or session, or cache...many ways to persist values for retrieval on other pages...
-- Craig Deelsnyder Microsoft MVP - ASP/ASP.NET This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Andrew J. Kelly |
last post by:
How do you data bind to a group of radio buttons? I can bind to an
individual radio button just fine but how do you bind a single field to all
the buttons so it works like a Radio button should?
...
|
by: Pete Nelson |
last post by:
Does anyone know of a way to bind a string collection to a datagrid?
Basically, I have an object, CreditPlans, and a string collection,
ModelNumbers. I'd like to bind the ModelNumbers collection...
|
by: Greg Linwood |
last post by:
I am wondering what the best approach to binding XML data to an asp:Table
from the Page_Load event in a code behind module?
I'm using VB.Net and initially approached this by adding a table to the...
|
by: AH |
last post by:
Hi all,
I noticed this strange behavior; I created a new control (example inherits
from textbox) and add a new property, then I bind this new property to a
field in my dataTable in a dataSet....
|
by: john wright |
last post by:
I have a dictionary oject I created and I want to bind a listbox to it. I
am including the code for the dictionary object.
Here is the error I am getting:
"System.Exception: Complex...
|
by: Eric |
last post by:
I wrote a query in Form_Open method but i didnt bind it with the
textbox. How to i bind this whole method with the text box, as right
now the textbox shows the last value of the recordset. The...
|
by: Mikus Sleiners |
last post by:
I have a control - textBox1 that is binded to objects propery - "Currency"
and another control - textBox2 (read only) that is also binded to same
propery.
Now, i have a situation where textbox1...
|
by: deekay |
last post by:
Im trying to update a database where our users have been
entering/editing all data using queries to now use forms instead. The
first step that I want to take is to convert the queries to forms in...
|
by: teddysnips |
last post by:
Back in the dim mists of antiquity I used to program in VBA for
Microsoft Access (hey, don't knock it - very useful tool for the right
application).
This had a really handy control in the...
|
by: Ronald S. Cook |
last post by:
Does anyone know why an IEnumerable might not bind to a DataGridView?
Thanks,
Ron
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
|
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...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
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...
|
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...
|
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,...
|
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...
| |