Variable from code behind into ASP page.

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!
 
M

Mark Rae

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
 
G

Guest

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
 
M

Mark Rae

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...
 
S

Steven Cheng[MSFT]

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.
 
G

Guest

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
 
M

Mark Rae

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)...
 
S

Steven Cheng[MSFT]

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,071
Latest member
MetabolicSolutionsKeto

Latest Threads

Top