M
Mark Hanson
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
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