using System;
using System.Collections;
using System.Text;
using Nexus.Core.Helpers;
namespace Nexus.Web
{
public class WebHelper : ViewHelper
{
public override string AlertsFor(string id)
{
string alert = null;
IList list = Alerts[id] as IList;
if (list == null) return alert;
if (list.Count == 1)
{
alert = HtmlMessage(list[0]);
}
else
{
alert = HtmlMessageList(list);
}
return alert;
}
/**
* Return Fault messages in HTML format.
*/
private string FaultMessages()
{
Exception e = Fault;
StringBuilder fault = new StringBuilder("[");
fault.Append(e.Message);
fault.Append("] ");
fault.Append(e.Source);
fault.Append(e.StackTrace);
return HtmlMessage(fault.ToString());
}
public override string AlertsText
{
get
{
if (HasFault)
{
string field_messages = HtmlMessageBuilder(Alerts);
StringBuilder alerts = new StringBuilder(field_messages);
alerts.Append(FaultMessages());
return alerts.ToString();
}
else
{
return HtmlMessageBuilder(Alerts);
}
}
}
public override string HintsFor(string id)
{
return HtmlMessageList(Hints[id] as IList);
}
public override string HintsText
{
get { return HtmlMessageBuilder(Hints); }
}
#region Message utilities
///
"); sb.Append(message.ToString()); sb.Append("
"); return sb.ToString(); } ///