-2
<% string **testString** = "Hello"; %>

<asp:label runat="server" ID="test123" *Text*="<% =**testString** %> "/>

how can i add a variable to the Text part in the label?

Chandan Kumar
  • 4,570
  • 4
  • 42
  • 62
Shane Slade
  • 13
  • 1
  • 3

2 Answers2

1

Initialize your variable like this

protected string abc;

and then assign value in page_load

abc= "test";
DataBind();

your aspx:

<asp:Label ID="myLabel" runat="server" Text='<%# abc%>' />
Mohammad
  • 132
  • 5
0

You can do something like:

<asp:Label runat="server" Text='<%= YourVariable %>' ID="test123" />

This is a bit of a duplicate. See this thread.

Community
  • 1
  • 1
Muhammad Qasim
  • 1,622
  • 14
  • 26