///############################################################ /// <summary> /// Renders the control to the specified HTML writer. /// </summary> /// <remarks> /// NOTE: This function will ignore any non-existant <c>sInputAlias</c>'s. /// </remarks> /// <param name="sInputAlias">String representing the HTML input's unique base name.</param> /// <param name="eInputType">Enumeration representing the input type to render.</param> /// <param name="sInitialValue">String representing the initial value of the input.</param> /// <param name="a_sInitialValues">Array of strings where each element represents an initial value of the input.</param> /// <param name="bForceInitialValue">Boolean value representing if the value of the input is always to be set to <paramref name="sInitialValue"/>/<paramref name="a_sInitialValues"/>.</param> /// <param name="sAttributes">String representing the additional HTML attributes to apply to the input.</param> /// <param name="writer">HtmlTextWriter object as automatically provided by the host ASPX page.</param> /// <returns>Boolean value indicating if it is necessary to raise the <c>GenerateHTML</c> event.</returns> ///############################################################ /// <LastUpdated>June 22, 2010</LastUpdated> public static bool DoRenderInput(string sInputAlias, enumInputTypes eInputType, string sInitialValue, string[] a_sInitialValues, bool bForceInitialValue, string sAttributes, HtmlTextWriter writer, IInputCollection oInputCollection) { bool bReturn = false; // //#### If the passed sInputAlias .Exists //if (oInputCollection.Exists(sInputAlias)) { //#### If this is a non-.cnCustom control if (eInputType != enumInputTypes.cnCustom) { //#### Flip our bReturn value to true bReturn = true; //#### If the sInputAlias .IsMultiValue, call the a_sInitialValues version of .GenerateHTML if (oInputCollection.Inputs(sInputAlias).IsMultiValue) { writer.Write(oInputCollection.GenerateHTML(sInputAlias, eInputType, a_sInitialValues, bForceInitialValue, sAttributes)); } //#### Else the sInputAlias .Is(not a)MultiValue, so call the sInitialValue version of .GenerateHTML else { writer.Write(oInputCollection.GenerateHTML(sInputAlias, eInputType, sInitialValue, bForceInitialValue, sAttributes)); } } //} //#### Return the above determined bReturn value to the caller return(bReturn); }
///############################################################ /// <summary> /// Renders the control to the specified HTML writer. /// </summary> /// <remarks> /// NOTE: This function will ignore any non-existant <c>sInputAlias</c>'s. /// </remarks> /// <param name="sInputAlias">String representing the HTML input's unique base name.</param> /// <param name="eInputType">Enumeration representing the input type to render.</param> /// <param name="sInitialValue">String representing the initial value of the input.</param> /// <param name="a_sInitialValues">Array of strings where each element represents an initial value of the input.</param> /// <param name="bForceInitialValue">Boolean value representing if the value of the input is always to be set to <paramref name="sInitialValue"/>/<paramref name="a_sInitialValues"/>.</param> /// <param name="sAttributes">String representing the additional HTML attributes to apply to the input.</param> /// <param name="writer">HtmlTextWriter object as automatically provided by the host ASPX page.</param> ///############################################################ /// <LastUpdated>February 15, 2010</LastUpdated> internal void RenderInput(string sInputAlias, enumInputTypes eInputType, string sInitialValue, string[] a_sInitialValues, bool bForceInitialValue, string sAttributes, HtmlTextWriter writer) { //#### If this is a .cnCustom control (as .DoRenderInput was unable to do the render itself) //#### NOTE: An event is required for the control as there is no other way not to call .Parent's .Render function, so this hook/event allows the developer to change the .Render if they so choose. if (!InputCollectionControlCommon.DoRenderInput(sInputAlias, eInputType, sInitialValue, a_sInitialValues, bForceInitialValue, sAttributes, writer, g_oInputCollection)) { //#### If the developer has defined delegate(s), raise the .GenerateHTML event if (GenerateHTML != null) { writer.Write(GenerateHTML(this, new GenerateHTMLEventArgs(sInputAlias, eInputType, sInitialValue, a_sInitialValues, sAttributes))); } //#### Else the required delegate(s) were not defined, so raise the error else { //! should use a CnException throw new NotImplementedException(); } } }
//#### Declare the required private constants //private const string g_cClassName = "Cn.Web.Inputs.Tools"; //########################################################################################## //# Public Static Functions //########################################################################################## ///############################################################ /// <summary> /// Formats the provided date. /// </summary> /// <remarks> /// If the passed <paramref>sInputSpecificFormat</paramref> is a null-string, its value is modified by reference to indicate the default date format as defined within <c>Renderer</c>'s loaded <c>Settings</c> (per the passed <paramref>eInputType</paramref>) that the <paramref>sDateToFormat</paramref> was formatted with. /// </remarks> /// <param name="sDateToFormat">String representing the date to format.</param> /// <param name="sInputSpecificFormat">Reference to a string representing the required date format.</param> /// <param name="eInputType">Enumeration representing the type of input to render.</param> /// <param name="oSettings">Cn.Web.Settings.Current instance representing the current enviroment.</param> /// <returns>String representing the formatted <paramref>sDateToFormat</paramref>.</returns> ///############################################################ /// <LastUpdated>November 13, 2009</LastUpdated> public static string FormatDateTime(string sDateToFormat, ref string sInputSpecificFormat, enumInputTypes eInputType, Settings.Current oSettings) { string sEndUserMessagesLanguageCode = oSettings.EndUserMessagesLanguageCode; string sReturn; Dates.enumWeekOfYearCalculations eWeekOfYearCalculation; //#### If the developer didn't pass in a sInputSpecificFormat if (sInputSpecificFormat.Length == 0) { //#### Determine the passed eInputType, resetting the sInputSpecificFormat to the related default value from .Settings switch (eInputType) { case enumInputTypes.cnDate: { sInputSpecificFormat = Settings.Internationalization.Value(Internationalization.enumInternationalizationValues.cnLocalization_Date_DateFormat, sEndUserMessagesLanguageCode); break; } case enumInputTypes.cnDateTime: { sInputSpecificFormat = Settings.Internationalization.Value(Internationalization.enumInternationalizationValues.cnLocalization_Date_DateTimeFormat, sEndUserMessagesLanguageCode); break; } case enumInputTypes.cnTime: { sInputSpecificFormat = Settings.Internationalization.Value(Internationalization.enumInternationalizationValues.cnLocalization_Date_TimeFormat, sEndUserMessagesLanguageCode); break; } } } //#### Collect the eWeekOfYearCalculation eWeekOfYearCalculation = Data.Tools.MakeEnum(Settings.Internationalization.Value(Internationalization.enumInternationalizationValues.cnLocalization_Date_WeekOfYearCalculationEnum, sEndUserMessagesLanguageCode), Dates.enumWeekOfYearCalculations.cnDefault); //#### If a sInputSpecificFormat was passed in (or successfully determined above) if (sInputSpecificFormat.Length > 0) { //#### Set the return value to the formatted sDateToFormat on the above determined sInputSpecificFormat //#### NOTE: The sInputSpecificFormat is defaulted to the localized default date/time format by the callers, it's not done here because we don't have access to the related oSettings object sReturn = Dates.Tools.FormatDateTime(sDateToFormat, sInputSpecificFormat, Settings.Internationalization, eWeekOfYearCalculation); } //#### Else a sInputSpecificFormat was not successfully determined above, so simply return the passed sDateToFormat as is else { sReturn = sDateToFormat; } //#### Return the above determined sReturn value to the caller return sReturn; }