Variable from code behind into ASP page.

  • Thread starter Thread starter vbMark
  • Start date Start date
V

vbMark

Isn't there a way to get your variable to display in a page with something
like this <% MyVar %>

That just isn't working for me. What am I missing?

Thanks!
 
Isn't there a way to get your variable to display in a page with something
like this <% MyVar %>

That just isn't working for me. What am I missing?

<% = MyVar %>

The equals sign is shorthand for Response.Write
 
Also I think the variable need to be marked as internal or protected to be
able to be accesed from the aspx source

HTH

Siva
 
Also I think the variable need to be marked as internal or protected to be
able to be accesed from the aspx source

protected or public - internal won't be visible...
 
Hi Mark,

As other members have mentioned, for ASP.NET, the classic ASP like inline
express such as <%= variable or function %> still work, you can use it to
display value in aspx template based on some page's member variable(or
helper function) in codebehind. Also, you need to make sure that the
variable or function is non-private (protected or public ) so that they can
be referenced in aspx template.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


This posting is provided "AS IS" with no warranties, and confers no rights.
 
Mark,

Internal works for me as protected/public. FYI I tested using ASP .net 2.0.
Here the point is that what Steven suggested. A non private variable will do
the job.

cheers

Siva
 
As other members have mentioned, for ASP.NET, the classic ASP like inline
express such as <%= variable or function %> still work, you can use it to
display value in aspx template based on some page's member variable(or
helper function) in codebehind. Also, you need to make sure that the
variable or function is non-private (protected or public ) so that they
can
be referenced in aspx template.

Er, yes I know, as per my earlier post (the one you appear to be replying
to)...
 
Thanks for your reply Mark,

Oh, I originally reply to the OP "vbMark", just haven't noticed that there
are more than one Mark here :-). Sure, appreciate your informative input
here.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


This posting is provided "AS IS" with no warranties, and confers no rights.
 
Back
Top