How to show the value of a variable in ASP.NET web forms?

I am trying to show the value of a variable as follows:

<% userTotalCount.ToString(); %> 

But I understand that at the beginning, the value is null, so I do not see anything on the page. Value userTotalCount Variables are set later in the Page_Load() event. How to show this value after installing it.

+5
source share
2 answers

You can set using label management. First take the control label, and then set the text to this label on page load event.

+6
source

The error is that you are not displaying a value. To do this on the page (note the first <%= )

 <%= userTotalCount.ToString(); %> 

this is a short cut for

 <% Response.Write(userTotalCount); %> 

The value is set on the Load page, then go back to render, so that you have it, but you don't render it.

You can also read: how to display the value of a variable in asp.net, which is set in the Page_Load function

+5
source

Source: https://habr.com/ru/post/1202044/


All Articles