How to use C# constant at ASP.Net page? -


The example below can be a little bit understandable, but that's because I'm focusing on syntax.

Say I have such C # code:

  public static class Foo {public press string bar = "Hello world"); }  

Now, I would like to use FU. Instead of continuously typing "Hello World" in ASP.NET every time. So I used this syntax:

  & lt; P & gt; & Lt;% = Foo.Bar% & gt; & Lt; / P & gt;  

This works even in cases where it works:

   

So, it also works with quotes even though I have issues, when quotes get high priority:

    

(note hash instead of equal sign) also does not work.

In addition to the code, try to avoid the C # code in addition to code label control in ASPX page And set it to text property with FU

myLabel.Text = Foo.Bar;

Then you have all the server side codes in the code back, it's very clean and readable to others.


Comments