J
John Smith
I want to be able to read and write standard server control properties
from code in a separate class file in vb.net. I learned how to access
the httpcontext of the calling .aspx page in the class file code, like
this:
Dim _Context As HttpContext = HttpContext.Current
which lets me do things like:
_Context.response.redirect("otherpage.aspx")
This is great. Now I need to learn how to read and write standard
server control properties from the code in a separate class file. For
example, if I have a label named label1 on the calling aspx page, how
do I do a label1.text = "hello" from code in the class file?
I need this to work if I call the code in the class file from any
number of different aspx files, the names of which I won't know up
front. Thus, I need the class file code to be able to sense what aspx
file is calling it, and take the appropriate steps.
I saw so many posts on this question, but the answers were all too
complex or too brief for me to understand. I need a complete example,
and assume I don't know what things like "cast" mean. I know that
this will be easy once I learn the trick, but I burned up most of
today trying to solve this.
In particular, do I need to do anything to the calling aspx page? I
suspect I need to change the server controls somehow so they are
publically available, butg I don't know.
On the class side, do I need to add any imports statements to the top?
Do I need to add any references? What code do I need to be able to
access arbitrary calling aspx pages?
Thanks!
from code in a separate class file in vb.net. I learned how to access
the httpcontext of the calling .aspx page in the class file code, like
this:
Dim _Context As HttpContext = HttpContext.Current
which lets me do things like:
_Context.response.redirect("otherpage.aspx")
This is great. Now I need to learn how to read and write standard
server control properties from the code in a separate class file. For
example, if I have a label named label1 on the calling aspx page, how
do I do a label1.text = "hello" from code in the class file?
I need this to work if I call the code in the class file from any
number of different aspx files, the names of which I won't know up
front. Thus, I need the class file code to be able to sense what aspx
file is calling it, and take the appropriate steps.
I saw so many posts on this question, but the answers were all too
complex or too brief for me to understand. I need a complete example,
and assume I don't know what things like "cast" mean. I know that
this will be easy once I learn the trick, but I burned up most of
today trying to solve this.
In particular, do I need to do anything to the calling aspx page? I
suspect I need to change the server controls somehow so they are
publically available, butg I don't know.
On the class side, do I need to add any imports statements to the top?
Do I need to add any references? What code do I need to be able to
access arbitrary calling aspx pages?
Thanks!