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.
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.
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
value
for
point
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...