public override string GetDesignTimeHtml()
{
// grab original HTML for base designer so user can resize control at design time
var originalHtml = base.GetDesignTimeHtml();
var lastIdx = originalHtml.IndexOf("<div", 1);
originalHtml = lastIdx > 0
? originalHtml.Substring(0, (originalHtml.IndexOf("<div", 1)))
: originalHtml.Remove(originalHtml.Length - 6, 6);
// remove all tabs and new lines
originalHtml = originalHtml
.Replace("\r", String.Empty)
.Replace("\n", String.Empty)
.Replace("\t", String.Empty);
string twitterHtml = null;
try {
switch(_twitter.Mode) {
case TwitterMode.Profile:
if(String.IsNullOrEmpty(_twitter.ScreenName))
throw new Exception("Please specify a screen name");
break;
default:
if(String.IsNullOrEmpty(_twitter.Search))
throw new Exception("Please specify a search keyword");
break;
}
var statuses = GenerateData();
if(statuses.Count > 0)
twitterHtml = RenderLayout(statuses);
else
twitterHtml = RenderEmptyData();
}
catch(Exception ex) {
if(twitterHtml == null)
twitterHtml = "<div>" + ex.Message + "</div>";
}
var styleSheetUrl = ViewControl.Page.ClientScript.GetWebResourceUrl(
this.GetType(), Constants.TwitterName + ".css");
var styleSheetHtml = String.Format(@"<link href=""{0}"" rel=""stylesheet"" type=""text/css""/>",
styleSheetUrl);
return originalHtml + styleSheetHtml + twitterHtml + "</div>";
}