473,498 Members | 1,379 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

accessing protected variables

I would like to access code behind .aspx.vb protected variables from
the aspx web page like this <%# _ProtectedVariable %>. The only way I
can get the value is if I do Me.DataBind on each postback. If I don't
call Me.DataBind then the protected variable is empty on the web page.
But I don't want to call DataBind which rebinds all my controls if
their DataSource is set. How can I make protected variables "stick"
without calling DataBind on the whole page? Viewstate has the same
issue, that Me.DataBind must be called in order to access the
viewstate value from the aspx web page.

In aspx form:
<%# _ProtectedVariable %>

In aspx.vb class:
Protected _ProtectedVariable as String

In aspx.vb Page_Load:
_ProtectedVariable = "Value"

In aspx.vb Page_PreRender:
'it works only if this line is not commented
'Me.DataBind
Nov 18 '05 #1
5 1838
Huh? No idea what you are talking about.

You have to reset all local variables when the page is recreated - because
since the page is recreated, so is everything on it. And if you don't set
your variables to a value every time, they will remain blank. This is not a
connected environment - not a winforms app. You get a brand new object
every time there is a request - not the one whose variables you set last
time, that one is long gone.

What does this have to do with the variables being protected?

"Mark Hanson" <ma*************@hotmail.com> wrote in message
news:c1**************************@posting.google.c om...
I would like to access code behind .aspx.vb protected variables from
the aspx web page like this <%# _ProtectedVariable %>. The only way I
can get the value is if I do Me.DataBind on each postback. If I don't
call Me.DataBind then the protected variable is empty on the web page.
But I don't want to call DataBind which rebinds all my controls if
their DataSource is set. How can I make protected variables "stick"
without calling DataBind on the whole page? Viewstate has the same
issue, that Me.DataBind must be called in order to access the
viewstate value from the aspx web page.

In aspx form:
<%# _ProtectedVariable %>

In aspx.vb class:
Protected _ProtectedVariable as String

In aspx.vb Page_Load:
_ProtectedVariable = "Value"

In aspx.vb Page_PreRender:
'it works only if this line is not commented
'Me.DataBind

Nov 18 '05 #2
<%# %> is a DataBinding expression. If you use a DataBinding expression, you
must call DataBind to bind the data.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
I get paid good money to
solve puzzles for a living

"Mark Hanson" <ma*************@hotmail.com> wrote in message
news:c1**************************@posting.google.c om...
I would like to access code behind .aspx.vb protected variables from
the aspx web page like this <%# _ProtectedVariable %>. The only way I
can get the value is if I do Me.DataBind on each postback. If I don't
call Me.DataBind then the protected variable is empty on the web page.
But I don't want to call DataBind which rebinds all my controls if
their DataSource is set. How can I make protected variables "stick"
without calling DataBind on the whole page? Viewstate has the same
issue, that Me.DataBind must be called in order to access the
viewstate value from the aspx web page.

In aspx form:
<%# _ProtectedVariable %>

In aspx.vb class:
Protected _ProtectedVariable as String

In aspx.vb Page_Load:
_ProtectedVariable = "Value"

In aspx.vb Page_PreRender:
'it works only if this line is not commented
'Me.DataBind

Nov 18 '05 #3
that is expected behavior. the databinder is what evalutes the binding
string expression <%# bindingExpression %>, and replaces it with its actual
value.

-- bruce (sqlwork.com)

"Mark Hanson" <ma*************@hotmail.com> wrote in message
news:c1**************************@posting.google.c om...
I would like to access code behind .aspx.vb protected variables from
the aspx web page like this <%# _ProtectedVariable %>. The only way I
can get the value is if I do Me.DataBind on each postback. If I don't
call Me.DataBind then the protected variable is empty on the web page.
But I don't want to call DataBind which rebinds all my controls if
their DataSource is set. How can I make protected variables "stick"
without calling DataBind on the whole page? Viewstate has the same
issue, that Me.DataBind must be called in order to access the
viewstate value from the aspx web page.

In aspx form:
<%# _ProtectedVariable %>

In aspx.vb class:
Protected _ProtectedVariable as String

In aspx.vb Page_Load:
_ProtectedVariable = "Value"

In aspx.vb Page_PreRender:
'it works only if this line is not commented
'Me.DataBind

Nov 18 '05 #4
Bruce and Kevin,

Thanks for your reply. Do you know of a way to bind variables without
binding the whole page? I prefer not to databind other controls on
postback but I do want to update certain variables and access them
from the aspx page. Controls have a DataBind method and I would like
to databind specific variables ideally.

Mark
MCP asp.net

"bruce barker" <no***********@safeco.com> wrote in message news:<eV**************@TK2MSFTNGP10.phx.gbl>...
that is expected behavior. the databinder is what evalutes the binding
string expression <%# bindingExpression %>, and replaces it with its actual
value.

-- bruce (sqlwork.com)

"Mark Hanson" <ma*************@hotmail.com> wrote in message
news:c1**************************@posting.google.c om...
I would like to access code behind .aspx.vb protected variables from
the aspx web page like this <%# _ProtectedVariable %>. The only way I
can get the value is if I do Me.DataBind on each postback. If I don't
call Me.DataBind then the protected variable is empty on the web page.
But I don't want to call DataBind which rebinds all my controls if
their DataSource is set. How can I make protected variables "stick"
without calling DataBind on the whole page? Viewstate has the same
issue, that Me.DataBind must be called in order to access the
viewstate value from the aspx web page.

In aspx form:
<%# _ProtectedVariable %>

In aspx.vb class:
Protected _ProtectedVariable as String

In aspx.vb Page_Load:
_ProtectedVariable = "Value"

In aspx.vb Page_PreRender:
'it works only if this line is not commented
'Me.DataBind

Nov 18 '05 #5
You can call DataBind on the Control which hosts the DataBinding expression.
If that is the Page, that is the Control that you need to call DataBind on.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
I get paid good money to
solve puzzles for a living

"Mark Hanson" <ma*************@hotmail.com> wrote in message
news:c1**************************@posting.google.c om...
Bruce and Kevin,

Thanks for your reply. Do you know of a way to bind variables without
binding the whole page? I prefer not to databind other controls on
postback but I do want to update certain variables and access them
from the aspx page. Controls have a DataBind method and I would like
to databind specific variables ideally.

Mark
MCP asp.net

"bruce barker" <no***********@safeco.com> wrote in message

news:<eV**************@TK2MSFTNGP10.phx.gbl>...
that is expected behavior. the databinder is what evalutes the binding
string expression <%# bindingExpression %>, and replaces it with its actual value.

-- bruce (sqlwork.com)

"Mark Hanson" <ma*************@hotmail.com> wrote in message
news:c1**************************@posting.google.c om...
I would like to access code behind .aspx.vb protected variables from
the aspx web page like this <%# _ProtectedVariable %>. The only way I
can get the value is if I do Me.DataBind on each postback. If I don't
call Me.DataBind then the protected variable is empty on the web page.
But I don't want to call DataBind which rebinds all my controls if
their DataSource is set. How can I make protected variables "stick"
without calling DataBind on the whole page? Viewstate has the same
issue, that Me.DataBind must be called in order to access the
viewstate value from the aspx web page.

In aspx form:
<%# _ProtectedVariable %>

In aspx.vb class:
Protected _ProtectedVariable as String

In aspx.vb Page_Load:
_ProtectedVariable = "Value"

In aspx.vb Page_PreRender:
'it works only if this line is not commented
'Me.DataBind

Nov 18 '05 #6

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

Similar topics

2
2266
by: Steven T. Hatton | last post by:
I find the surprising. If I derive Rectangle from Point, I can access the members of Point inherited by Rectangle _IF_ they are actually members of a Rectangle. If I have a member of type Point...
3
2779
by: Vivek Sharma | last post by:
Hi, I have created a dropdownlist as a web user control. I am using its multiple instances on the webpage. How do I access the selectedValue of each instance? All the instances have different...
9
5378
by: Bob Day | last post by:
VS 2003, vb.net , sql msde... I have an application with multiple threads running. Its a telephony application where each thread represents a telephone line. For code that would be the same...
8
2729
by: dwok | last post by:
I have been wondering this for a while now. Suppose I have a class that contains some private member variables. How should I access the variables throughout the class? Should I use properties that...
11
3793
by: Kevin Prichard | last post by:
Hi all, I've recently been following the object-oriented techiques discussed here and have been testing them for use in a web application. There is problem that I'd like to discuss with you...
5
2464
by: TS | last post by:
is it preferred to access member variables directly in code, on the page that declared them, versus going thru a property accessor? I would think that since theres no security concerns or anything...
5
5833
by: MrJim | last post by:
How should variables be declared and referenced in both the base and derived form so they can be accessed?
4
8482
by: Joseph Paterson | last post by:
Hi all, I'm having some trouble with the following code (simplified to show the problem) class Counter { protected: int m_counter; }
8
10802
by: GaryDean | last post by:
I have a Wizard page and need to affect the next and previous buttons from my code-behind. I've googled around and found two solutions, and neither appear to work. I can access the SideBarList...
0
7124
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,...
0
7200
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...
1
6884
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...
0
7375
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...
1
4904
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...
0
4586
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...
0
3078
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
651
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
287
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.