Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Accessing code-behind variables from page code

I have the following two pages:

  1. Default.aspx
  2. Default.aspx.cs

How do I access variables in the code-behind file (Default.aspx.cs) from my embedded code in (Default.aspx) with the <% %> syntax?

like image 367
Birdman Avatar asked Dec 13 '11 15:12

Birdman


1 Answers

Any public or protected (but not private, the "page" itself inherits from the code-behind Page class) class-level member can be accessed in this way. For example, if your code-behind class has a property:

protected string SomeValue { get; set; }

Then in your aspx code you can refer to it:

<% =SomeValue %>
like image 159
David Avatar answered Jan 02 '23 17:01

David