Tip : displaying default text for empty controls

Tip : displaying default text for empty controls

Posted on January 04, 2008 0 Comments

The content you're reading is getting on in years
This post is on the older side and its content may be out of date.
Be sure to visit our blogs homepage for our latest news, updates and information.

One of our users has asked how to display a default text for empty control when editing page in Sitefinity. The scenario is following: you have created a custom control, user drags it onto the page and because no properties have been set, user only sees blank space. What we want to do is display some user friendly message, something like on the screenshot below.

Empty control screenshot

It is quite simple to achieve this. All you have to do is implement IEmptyControl interface in your control. The IEmptyControl interface defines a boolean property „IsEmpty“ in which you create the logic that will define the control as empty or not. In addition to that, interface defines a string function which simply returns the text you want to display if control is empty. And that's it. Take a look at the code below which illustrates this.

Empty control code

I have prepared a sample control which demonstrates this, so you can go ahead and download it from here, though the implementation is really trivial.

A point to note here is that you could also use IsEmpty property together with Control.DesignMode property in your CreateChildControls method to create a more complex display for empty controls (not just text).

Hope this helps.
progress-logo

The Progress Team

View all posts from The Progress Team on the Progress blog. Connect with us about all things application development and deployment, data integration and digital business.

Comments

Comments are disabled in preview mode.
Topics

Sitefinity Training and Certification Now Available.

Let our experts teach you how to use Sitefinity's best-in-class features to deliver compelling digital experiences.

Learn More
Latest Stories
in Your Inbox

Subscribe to get all the news, info and tutorials you need to build better business apps and sites

Loading animation