Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I call a csharp variable in .aspx page?

In code behind page I create a variable like this (it belongs to one of the class)

string login_status = "you are not logged in";

I want to show this variable value in my Default.aspx page. What do I do?

like image 562
dave Avatar asked Nov 17 '25 14:11

dave


2 Answers

You can create a variable of type string with protected access modifier and call it on your web page using:

<%= login_status %>
like image 100
aster Avatar answered Nov 20 '25 03:11

aster


Drop a label onto your aspx page:

<asp:Label ID="Label1" runat="server"></asp:Label>

then in the codebehind, say:

Label1.Text = login_status;
like image 39
markpsmith Avatar answered Nov 20 '25 03:11

markpsmith



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!