Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to show a variable value in ASP.NET Web Forms?

Tags:

c#

asp.net

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.

like image 675
splash27 Avatar asked Sep 08 '14 05:09

splash27


1 Answers

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

like image 113
Aristos Avatar answered Nov 08 '22 03:11

Aristos