Reputation: 21
I have declared a variable in code behind the variable name is progressbar which is of int type
to access this variable in the same asp.net page i am using this code
<table align="center" border="1" cellpadding="0" cellspacing="0" frame="border"
style="border-color: #FF0000" width="100%">
<tr>
<td bgcolor="#FF0066" colspan="0" rowspan="0" width="<%= progressbar %>%">
</td>
<td colspan="0" rowspan="0">
</td>
</tr>
i have used both <%= progressbar %>
and <%# progressbar %>
but not able to access this variable.
Can you tell me how can I access this variable from c# code behind to the asp.net page
Upvotes: 1
Views: 2830
Reputation: 2161
Make sure the variable you're trying to access is not private
You should be able to accesss it like this <%= progressbar %>
within the class write
public int progressbar = 0;
Upvotes: 4
Reputation: 65166
All variables in C# are local variables, and they're only visible inside the function they were declared in. Make your thing a field or a property instead, and make sure it's either protected
or public
.
Upvotes: 2