Could someone please advise what the "correct" method is for adding HTML content to an ASP.NET page dynamically?
I am aware of the following declarative method.
//Declaration
<%= MyMethodCall() %>
//And in the code behind.
protected String MyMethodCall()
{
return "Test Value";
}
Is there a better or best practice way?
EDIT: I am building a Galleriffic photo gallery dynamically depending on the images located in a specific folder.
Depends what you want to do.
For controls/text I normally use a
LiteralControl
and set theText
property as the HTML I want to add, then this control can be added anywhere on the page that you want it to appearLiteralControl reference is here
ok seeing as you want it for Galleriffic, I guess it would pseudo-appear as such...
There are several ways to do that, which to use really depends on your scenario and preference.
Aspx :
Code behind :
Another option