Tip : displaying default text for empty controls

Tip : displaying default text for empty controls

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.

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 are disabled in preview mode.
Latest Stories in
Your Inbox
More From Progress
5 Questions Automakers Should Ask to Improve Asset Uptime
Download Whitepaper
2018 Gartner Magic Quadrant Web Content Management (WCM)
Download Whitepaper
What Serverless Means for Enterprise Apps
Watch Webinar