HTML Helpers in Webform?

I have an old site that I want to use something like HTML helpers to create custom HTML (in this case, complex buttons). I know how this works in ASP.NET MVC, but how can I do this in Webform (not Razor).

I read suggestions for static methods like this:

public class Helpers { public static string Label1(string target, string text) { return String.Format("<label for= '{0}'>{1}</label>", target, text); } } 

But how is it used in webform?

Best regards

+4
source share
2 answers

In your decision. Add a special ASP.net Folder called code. Then insert your Helpers.cs file into it. Then you can access it.

+1
source

Put Helpers.cs in your App_Code folder, then you can call it like this from your aspx file:

 <div class="example> <%= Helpers.Label1("some", "text") %> </div> 
+4
source

All Articles