|
using System;
using System.Text;
using System.Web.UI;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using Microsoft.SharePoint.Utilities;
namespace OWSControls
{
public class OWSDateField : OWSBase
{
#region construction
/// <summary>
/// Default constructor
/// </summary>
public OWSDateField() { }
#endregion
#region custom properties
/// <summary>
/// Gets or set the number date in a .NET date time format.
/// </summary>
public DateTime DateTime
{
get { return SPUtility.CreateSystemDateTimeFromXmlDataDateTimeFormat(Value); }
set { Value = SPUtility.CreateISO8601DateTimeFromSystemDateTime(value); }
}
/// <summary>
/// Gets or set whether or not this control presents a date only value.
/// </summary>
public bool DateOnly
{
get
{
if (ViewState["DateOnly"] == null)
DateOnly = false;
return (bool)ViewState["DateOnly"];
}
set { ViewState["DateOnly"] = value; }
}
/// <summary>
/// Gets or set whether or not to hide descriptions.
/// </summary>
public bool HideDescription
{
get
{
if (ViewState["HideDescription"] == null)
HideDescription = false;
return (bool)ViewState["HideDescription"];
}
set { ViewState["HideDescription"] = value; }
}
#endregion
#region overridden properties
/// <summary>
/// Gets the test string representation of the date.
/// </summary>
public override string Text
{
get
{
if (DateOnly)
return DateTime.ToString("dddd, MMMM d, yyyy");
return DateTime.ToString("dddd, MMMM d, yyyy h:mm tt");
}
}
#endregion
#region overridden methods
/// <summary>
/// Renders the OWS Control
/// </summary>
/// <param name="wtr">writes out the text control information</param>
protected override void Render(HtmlTextWriter wtr)
{
wtr.Write(
"<SCRIPT>" +
"fld=new DateField(frm, '{0}', '{1}', '{2}'); " +
"fld.fDateOnly = {3}; " +
"fld.fHideDescription = {4}; " +
"fld.caltype = 1; " +
"fld.fRequired = {5}; " +
"fld.BuildUI(); " +
"</SCRIPT>",
UniqueID,
Display,
JavaScriptValue,
DateOnly.ToString().ToLower(),
HideDescription.ToString().ToLower(),
Required.ToString().ToLower()
);
}
#endregion
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.