Reputation: 2107
I try to show variable value like this:
<% userTotalCount.ToString(); %>
But I understand that at the start the value is null, that's why I can't see anything on the page. Value of userTotalCount
Variable sets later in Page_Load()
event. How to show this value after it being set.
Upvotes: 9
Views: 17674
Reputation: 66641
The error is that you do not render the value. To render it on page use (note the first <%=
)
<%= userTotalCount.ToString(); %>
this is a short cut for
<% Response.Write(userTotalCount); %>
The value is set on PageLoad, then come back to render there, so you have it, but you do not render it.
You can also read : how to display variable value in asp.net which is set in Page_Load function
Upvotes: 11
Reputation: 5962
You can set using label control .
First take a label control
, and then set the text to that label
on page load
event .
Upvotes: 7