This is simple stuff, but I wanted to store these code snippets somewhere for easy re-use...
This is how to do databinding with a Repeater control in ASP.NET.
In the ASPX file:
In the code-behind file:
protected string GetTitle(RepeaterItem item)
{
PageData page = (PageData)item.DataItem;
return page.PageName;
}
In Page_Load(), we connect the repeater to a datasource (in this case a collection of pages from EPiServer).
GetTitle() is a function that is called by the ItemTemplate in the repeater for extracting the string to include in the page (in this case the name of the page). Eval() can also be used directly in the ASPX file to display the value of a property.
As I said, easy stuff, but now I don't have to write the code again the next time I need it...
Every serious web designer writes flashy Html with fake content starting with the famous "Lorem ipsum" phrase. Now the rest of us can look just as professional using this handy generator
Now all I have to do is get a freaky haircut, trashy clothing and grow a beard...
/Emil
In some cases it may be useful to detect when an EPiServer page is displayed in DOPE (Direct On-Page Editing) mode rather than the "normal" View mode. This is how to do it:
This is the only way I have found to do this, but it feels like there should be a DOPE flag somewhere in the EPiServer API. If anyone has found it, please leave a comment
Have you ever written en EPiServer plugin for the Action Window? If so, you have probably noticed how irritatingly narrow it is. Luckily, the width can easily be adjusted by your plugin using this code:
This is the same code that the built-in EPiServer File Manager uses, so I think we can regard it as well tested. It has worked well for me, hope it helps you as well.
[powered by WordPress.]
jour·nal n. A personal record of occurrences, experiences, and reflections kept on a regular basis; a diary.
36 queries. 0.639 seconds