public VelocityHelper(basePortalModule _bpm, EffectDB _Theme, String _path = "Effect") { Theme = _Theme; bpm = _bpm; Init(_bpm, _path); }
/// <summary> /// 绑定数据项到前台 /// </summary> public void BindDataItem(EffectDB EffectDB) { Hashtable Puts = new Hashtable(); TemplateFormat xf = new TemplateFormat(this); //读取需要载入的参数 Puts.Add("EffectName", Settings_ResultName); Puts.Add("ThemeName", Settings_ResultThemeName); //读取当前Form的结果 DNNGo_PowerForms_Content DataItem = DNNGo_PowerForms_Content.FindByKeyForEdit(FormID); Puts.Add("DataItem", DataItem); if (DataItem != null && DataItem.ID > 0 && !String.IsNullOrEmpty(DataItem.ContentValue)) { List <DNNGo_PowerForms_ContentItem> ContentList = Common.Deserialize <List <DNNGo_PowerForms_ContentItem> >(DataItem.ContentValue); Puts.Add("ContentList", ContentList); } //查看是否是结果列表页 if (!EffectDB.IsDetail) { Int32 RecordCount = 0; QueryParam qp = new QueryParam(); qp.Orderfld = DNNGo_PowerForms_Content._.ID; qp.OrderType = 1; qp.PageSize = 10; qp.PageIndex = PageIndex; qp.Where.Add(new SearchParam("ModuleId", ModuleId, SearchType.Equal)); List <DNNGo_PowerForms_Content> Results = DNNGo_PowerForms_Content.FindAll(qp, out RecordCount); Puts.Add("ResultList", Results); if (RecordCount > qp.PageSize) { Puts.Add("Pager", new Pager(qp.PageIndex, qp.PageSize, ModuleId, RecordCount, EnumPageType.DnnURL, false).CreateHtml());//分页 } else { Puts.Add("Pager", ""); } } liContent.Text = HttpUtility.HtmlDecode(ViewTemplate(EffectDB, "Effect.html", Puts, xf, "Result")); }
/// <summary> /// 绑定数据 /// </summary> private void BindDataToPage() { EffectDB ResultDB = Setting_ResultDB; if (!(ResultDB != null && String.IsNullOrEmpty(ResultDB.Name))) { //绑定样式表到内容框 String StyleFile = Server.MapPath(String.Format("{0}Results/{1}/Themes/{2}/Style.css", ModulePath, Settings_ResultName, Settings_ResultThemeName)); using (StreamReader m_streamReader = File.OpenText(StyleFile)) { this.txtContent.Value = m_streamReader.ReadToEnd(); m_streamReader.Close(); } } }
/// <summary> /// 绑定数据项到前台 /// </summary> public void BindDataItem(EffectDB EffectDB, String ErrorMessage) { //防止重复提交之用 //SubmitButton.Attributes["onclick"] = Page.GetPostBackEventReference(this.SubmitButton) ; Hashtable Puts = new Hashtable(); TemplateFormat xf = new TemplateFormat(this); xf.CtlButton = SubmitButton; //读取需要载入的参数 Puts.Add("FieldList", FieldList); //读取需要载入的分组 List <DNNGo_PowerForms_Group> GroupList = new List <DNNGo_PowerForms_Group>(); if (Setting_EffectDB.Group) { GroupList = DNNGo_PowerForms_Group.FindAllByView(ModuleId); if (GroupList.Count == 0) { DNNGo_PowerForms_Group defultGroup = new DNNGo_PowerForms_Group(); defultGroup.ID = 0; defultGroup.Name = "Default Group"; GroupList.Add(defultGroup); } } Puts.Add("GroupList", GroupList); Puts.Add("EffectName", Settings_EffectName); Puts.Add("ThemeName", Settings_EffectThemeName); Puts.Add("ErrorMessage", ErrorMessage); Puts.Add("captchaErrorMessage", ErrorMessage); //判断表单版本,用来判断是否控制每个人只能填写一次 Puts.Add("DisplayForm", DisplayForm()); if (!String.IsNullOrEmpty(iFrame) && iFrame.IndexOf("iFrame", StringComparison.CurrentCultureIgnoreCase) >= 0) { liContent.Text = HttpUtility.HtmlDecode(ViewTemplate(EffectDB, "iFrame.html", Puts, xf)); } else { liContent.Text = HttpUtility.HtmlDecode(ViewTemplate(EffectDB, "Effect.html", Puts, xf)); } }
/// <summary> /// 页面加载 /// </summary> protected void Page_Init(object sender, EventArgs e) { try { if (!String.IsNullOrEmpty(Settings_ResultName)) { if (!String.IsNullOrEmpty(Settings_ResultThemeName)) { EffectDB EffectDB = Setting_ResultDB; if (!IsPostBack) { //绑定数据项到前台 BindDataItem(EffectDB); } //需要载入当前设置效果的主题CSS文件 String ThemeName = String.Format("{0}_{1}", Settings_ResultName, Settings_ResultThemeName); String ThemePath = String.Format("{0}Results/{1}/Themes/{2}/Style.css", ModulePath, Settings_ResultName, Settings_ResultThemeName); BindStyleFile(ThemeName, ThemePath); BindXmlDBToPage(EffectDB, "Result"); } else { //未定义效果对应的主题 liContent.Text = ""; } } else { //未绑定效果 liContent.Text = ""; } } catch (Exception ex) { DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException(this, ex); } }
/// <summary> /// 上传文件 /// </summary> /// <param name="hpFile"></param> /// <param name="pmb"></param> /// <returns></returns> public static String UploadFileByCustom(HttpPostedFile httpFile, EffectDB DB, basePortalModule pmb) { String FileName = httpFile.FileName.Replace(" ", "_"); if (FileName.IndexOf(@"\") >= 0) { FileName = FileName.Substring(FileName.LastIndexOf(@"\"), FileName.Length - FileName.LastIndexOf(@"\")).Replace(@"\", ""); } String Extension = Path.GetExtension(FileName).Replace(".", ""); //构造保存路径 String FileUrl = FileName; FileInfo file = new FileInfo(pmb.MapPath(String.Format("{0}Effects/{1}/{2}", pmb.ModulePath, DB.Name, FileName))); if (!file.Directory.Exists) { file.Directory.Create(); } int ExistsCount = 1; //检测文件名是否存在 while (file.Exists) { FileUrl = String.Format("{0}_{1}.{2}", FileName.Replace("." + Extension, ""), ExistsCount, Extension); file = new FileInfo(pmb.MapPath(String.Format("{0}Effects/{1}/{2}", pmb.PortalId, DB.Name, FileUrl))); ExistsCount++; } //保存文件到文件夹 httpFile.SaveAs(file.FullName); return(FileUrl); }
/// <summary> /// 格式化内容模版 /// </summary> /// <param name="SubmitContent">提交的内容实体</param> /// <param name="Template">模版</param> /// <returns></returns> public String FormatContent(DNNGo_PowerForms_Content SubmitContent, String Template, List <DNNGo_PowerForms_ContentItem> ContentList) { TemplateFormat xf = new TemplateFormat(this); xf.FieldList = FieldList; if (!String.IsNullOrEmpty(Template)) { //为了节约效率,需要先判断模版内有无需要替换的标签 if (Template.IndexOf("[UserName]", StringComparison.CurrentCultureIgnoreCase) >= 0) { Template = Common.ReplaceNoCase(Template, "[UserName]", SubmitContent.UserName); } if (Template.IndexOf("[CultureInfo]", StringComparison.CurrentCultureIgnoreCase) >= 0) { Template = Common.ReplaceNoCase(Template, "[CultureInfo]", SubmitContent.CultureInfo); } if (Template.IndexOf("[SubmitTime]", StringComparison.CurrentCultureIgnoreCase) >= 0) { Template = Common.ReplaceNoCase(Template, "[SubmitTime]", SubmitContent.LastTime.ToString()); } if (Template.IndexOf("[SubmitIP]", StringComparison.CurrentCultureIgnoreCase) >= 0) { Template = Common.ReplaceNoCase(Template, "[SubmitIP]", SubmitContent.LastIP); } if (Template.IndexOf("[Email]", StringComparison.CurrentCultureIgnoreCase) >= 0) { Template = Common.ReplaceNoCase(Template, "[Email]", SubmitContent.Email); } //if (Template.IndexOf("[]", StringComparison.CurrentCultureIgnoreCase) >= 0) Template = Common.ReplaceNoCase(Template, "[]", ""); //2014.4.30 新增更多用户的Token,但需要是用户登陆时提交的才行. if (SubmitContent.LastUser > 0) { DotNetNuke.Entities.Users.UserInfo uInfo = DotNetNuke.Entities.Users.UserController.GetUserById(PortalId, SubmitContent.LastUser); if (uInfo != null && uInfo.UserID > 0) { if (Template.IndexOf("[DisplayName]", StringComparison.CurrentCultureIgnoreCase) >= 0) { Template = Common.ReplaceNoCase(Template, "[DisplayName]", uInfo.DisplayName); } if (Template.IndexOf("[LastName]", StringComparison.CurrentCultureIgnoreCase) >= 0) { Template = Common.ReplaceNoCase(Template, "[LastName]", uInfo.LastName); } if (Template.IndexOf("[FirstName]", StringComparison.CurrentCultureIgnoreCase) >= 0) { Template = Common.ReplaceNoCase(Template, "[FirstName]", uInfo.FirstName); } if (Template.IndexOf("[UserRole]", StringComparison.CurrentCultureIgnoreCase) >= 0) { Template = Common.ReplaceNoCase(Template, "[UserRole]", Common.GetStringByList(uInfo.Roles)); } } else { if (Template.IndexOf("[DisplayName]", StringComparison.CurrentCultureIgnoreCase) >= 0) { Template = Common.ReplaceNoCase(Template, "[DisplayName]", "Anonymous users"); } if (Template.IndexOf("[LastName]", StringComparison.CurrentCultureIgnoreCase) >= 0) { Template = Common.ReplaceNoCase(Template, "[LastName]", "--"); } if (Template.IndexOf("[FirstName]", StringComparison.CurrentCultureIgnoreCase) >= 0) { Template = Common.ReplaceNoCase(Template, "[FirstName]", "--"); } if (Template.IndexOf("[UserRole]", StringComparison.CurrentCultureIgnoreCase) >= 0) { Template = Common.ReplaceNoCase(Template, "[UserRole]", "--"); } } } else { if (Template.IndexOf("[DisplayName]", StringComparison.CurrentCultureIgnoreCase) >= 0) { Template = Common.ReplaceNoCase(Template, "[DisplayName]", "Anonymous users"); } if (Template.IndexOf("[LastName]", StringComparison.CurrentCultureIgnoreCase) >= 0) { Template = Common.ReplaceNoCase(Template, "[LastName]", "--"); } if (Template.IndexOf("[FirstName]", StringComparison.CurrentCultureIgnoreCase) >= 0) { Template = Common.ReplaceNoCase(Template, "[FirstName]", "--"); } if (Template.IndexOf("[UserRole]", StringComparison.CurrentCultureIgnoreCase) >= 0) { Template = Common.ReplaceNoCase(Template, "[UserRole]", "--"); } } //循环打印所有的字段值 foreach (DNNGo_PowerForms_ContentItem item in ContentList) { String item_key = String.Format("[{0}]", item.FieldName); if (Template.IndexOf(item_key, StringComparison.CurrentCultureIgnoreCase) >= 0) { Template = Common.ReplaceNoCase(Template, item_key, xf.ViewContentValue(item)); } } if (Template.IndexOf("[Content]", StringComparison.CurrentCultureIgnoreCase) >= 0) { EffectDB EffectDB = Setting_EffectDB; Hashtable Puts = new Hashtable(); String FormUrl = Globals.NavigateURL(TabId); if (FormUrl.ToLower().IndexOf("http://") < 0 && FormUrl.ToLower().IndexOf("https://") < 0) { FormUrl = string.Format("{2}://{0}{1}", WebHelper.GetHomeUrl(), FormUrl, PortalSettings.SSLEnabled ? "https" : "http"); } Puts.Add("ContentList", ContentList); Puts.Add("FieldList", FieldList); Puts.Add("EffectName", Settings_EffectName); Puts.Add("ThemeName", Settings_EffectThemeName); Puts.Add("Group", EffectDB.Group);//有分组的时候才会显示分组 Puts.Add("FormUrl", FormUrl); Puts.Add("FormTitle", ModuleConfiguration.ModuleTitle); Puts.Add("ExtraTracking", Settings_ExtraTracking);//是否启用跟踪 Template = Common.ReplaceNoCase(Template, "[Content]", ViewTemplate(EffectDB, "EmailTable.html", Puts, xf)); } } return(Template); }
/// <summary> /// 页面加载 /// </summary> protected void Page_Init(object sender, EventArgs e) { try { if (IncludeMultipleFileUpload) { //载入多文件上传脚本 LoadPluploadScript(); } String SubmitPostAction = WebHelper.GetStringParam(Request, SubmitButton.UniqueID, ""); //if (!String.IsNullOrEmpty(SubmitPostAction)) //{ // SubmitButton_Click(null, null); //} if (!String.IsNullOrEmpty(Settings_EffectName)) { if (!String.IsNullOrEmpty(Settings_EffectThemeName)) { EffectDB EffectDB = Setting_EffectDB; EffectGroup = EffectDB.Group;//指示前台当前效果是否带分组 //String captchaErrorMessage = mTips.Post(this); if (!IsPostBack)// || !String.IsNullOrEmpty(captchaErrorMessage)) { //绑定数据项到前台 BindDataItem(EffectDB, ""); //BindDataItem(EffectDB, captchaErrorMessage); if (EffectDB.Name.IndexOf("Effect_04_FancyBox") >= 0 || EffectDB.Name.IndexOf("Effect_05_HoverFancyBox") >= 0) { _Fancybox = true; } } if (!IsPostBack) { //绑定隐藏控件域(防止提交垃圾) BindHiddenField(); } //需要载入当前设置效果的主题CSS文件 String ThemeName = String.Format("{0}_{1}", Settings_EffectName, Settings_EffectThemeName); String ThemePath = String.Format("{0}Effects/{1}/Themes/{2}/Style.css", ModulePath, Settings_EffectName, Settings_EffectThemeName); BindStyleFile(ThemeName, ThemePath); BindXmlDBToPage(EffectDB, "Effect"); } else { //未定义效果对应的主题 liContent.Text = ""; } } else { //未绑定效果 liContent.Text = ""; } } catch (Exception ex) { DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException(this, ex); } }
/// <summary> /// 效果列表行绑定 /// </summary> protected void gvEffectList_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { DirectoryInfo EffectDir = e.Row.DataItem as DirectoryInfo; if (!EffectDir.Exists) { EffectDir.Create(); } //获取效果数据的XML String EffectDBPath = String.Format("{0}\\EffectDB.xml", EffectDir.FullName); if (File.Exists(EffectDBPath)) { XmlFormat xf = new XmlFormat(EffectDBPath); EffectDB ResultDB = xf.ToItem <EffectDB>(); //构造图片的路径 Image imgPicture = e.Row.FindControl("imgPicture") as Image; imgPicture.Attributes.Add("onError", String.Format("this.src='{0}Resource/images/no_image.png'", ModulePath)); if (!String.IsNullOrEmpty(ResultDB.Thumbnails)) { if (ResultDB.Thumbnails.IndexOf("http://", StringComparison.CurrentCultureIgnoreCase) >= 0) { imgPicture.ImageUrl = ResultDB.Thumbnails; } else { imgPicture.ImageUrl = String.Format("{0}Results/{1}/{2}", ModulePath, ResultDB.Name, ResultDB.Thumbnails); } } //构造效果标题描述 Label labName = e.Row.FindControl("labName") as Label; Label labDescription = e.Row.FindControl("labDescription") as Label; Label labVersion = e.Row.FindControl("labVersion") as Label; labName.Text = ResultDB.Name; labDescription.Text = ResultDB.Description; labVersion.Text = ResultDB.Version; //演示地址 if (!String.IsNullOrEmpty(ResultDB.DemoUrl)) { Literal LiDemoUrl = e.Row.FindControl("LiDemoUrl") as Literal; LiDemoUrl.Text = String.Format("<a href=\"{0}\" target=\"_blank\" class=\"btn btn-default btn-sm\"><i class=\"fa clip-link\"></i> {1}</a>", ResultDB.DemoUrl, ViewResourceText("labDemoUrl", "Demo Url")); } //响应式 if (ResultDB.Responsive) { Literal LiResponsive = e.Row.FindControl("LiResponsive") as Literal; LiResponsive.Text = String.Format("<a class=\"btn btn-default btn-sm\"><i class=\"fa clip-embed\"></i> {0}</a>", ViewResourceText("labResponsive", "Responsive")); } //应用效果的按钮 LinkButton btnApply = e.Row.FindControl("btnApply") as LinkButton; HyperLink hlThemeName = e.Row.FindControl("hlThemeName") as HyperLink; btnApply.CommandArgument = ResultDB.Name; if (!String.IsNullOrEmpty(Settings_ResultName) && Settings_ResultName == ResultDB.Name)//判断设置效果是否为当前效果 { btnApply.Text = String.Format("<i class=\"fa fa-stop\"></i> {1}", ModulePath, Localization.GetString("btnApply_Stop", this.LocalResourceFile)); btnApply.Enabled = false; btnApply.CssClass = "btn btn-danger"; hlThemeName.Text = String.Format("<i class=\"fa clip-cogs\"></i> {0}", Settings_ResultThemeName); hlThemeName.NavigateUrl = xUrl("Effect_Options"); } else { btnApply.Text = String.Format("<i class=\"fa fa-play-circle-o\"></i> {1}", ModulePath, Localization.GetString("btnApply_Play", this.LocalResourceFile)); btnApply.CssClass = "btn btn-success"; hlThemeName.Visible = false; } } } }
/// <summary> /// 绑定数据 /// </summary> private void BindDataToPage() { EffectDB XmlDB = Setting_EffectDB; if (!(XmlDB != null && String.IsNullOrEmpty(XmlDB.Name))) { lblEffectName.Text = XmlDB.Name; lblEffectDescription.Text = XmlDB.Description; //绑定效果的主题 String EffectDirPath = String.Format("{0}Effects/{1}/Themes/", Server.MapPath(ModulePath), XmlDB.Name); DirectoryInfo EffectDir = new DirectoryInfo(EffectDirPath); if (!EffectDir.Exists) { EffectDir.Create(); } DirectoryInfo[] ThemeDirs = EffectDir.GetDirectories(); List <KeyValueEntity> dirs = new List <KeyValueEntity>(); if (ThemeDirs != null && ThemeDirs.Length > 0) { foreach (DirectoryInfo dir in ThemeDirs) { KeyValueEntity dirEntity = new KeyValueEntity(); dirEntity.Key = dir.Name; FileInfo imgFile = new FileInfo(MapPath(String.Format("{0}Effects/{1}/Themes/{2}/image.jpg", ModulePath, XmlDB.Name, dir.Name))); if (imgFile.Exists) { dirEntity.Value = String.Format("{0}Effects/{1}/Themes/{2}/image.jpg", ModulePath, XmlDB.Name, dir.Name); } else { dirEntity.Value = String.Format("http://www.dnngo.net/DesktopModules/DNNGo_PowerForms/Effects/{0}/Themes/{1}/image.jpg", XmlDB.Name, dir.Name); } dirs.Add(dirEntity); } WebHelper.BindList <KeyValueEntity>(ddlThemeName, dirs, "Key", "Value"); } WebHelper.SelectedListByText(ddlThemeName, Settings_EffectThemeName); // hfThemeThumbnails.Value = String.Format("{0}Effects/{1}/Themes/[EffectThemeName]/image.jpg", ModulePath, XmlDB.Name); if (!String.IsNullOrEmpty(Settings_EffectThemeName)) { imgThemeThumbnails.Attributes.Add("onError", String.Format("this.src='{0}Resource/images/no_image.png'", ModulePath)); imgThemeThumbnails.ToolTip = Settings_EffectThemeName; KeyValueEntity dirEntity = dirs.Find(r1 => r1.Key.IndexOf(Settings_EffectThemeName, StringComparison.CurrentCultureIgnoreCase) >= 0); imgThemeThumbnails.ImageUrl = dirEntity != null?dirEntity.Value.ToString() : ""; imgThemeThumbnails.Visible = true; } } ////获取效果参数 //List<SettingEntity> EffectSettingDB = Setting_SkinEffectSettingDB; //if (EffectSettingDB != null && EffectSettingDB.Count > 0) //{ // //绑定参数项 // RepeaterTheme.DataSource = EffectSettingDB; // RepeaterTheme.DataBind(); //} }
/// <summary> /// 绑定方案项 /// </summary> private void BindDataItem() { //取出当前的方案实体,并绑定到相应的控件上 DNNGo_PowerForms_Field fieldItem = FieldItem; if (fieldItem == null) { fieldItem = new DNNGo_PowerForms_Field(); } if (fieldItem.ID > 0) { //更新方案 //需要将几个控件设置为不可操作状态 txtName.Enabled = false; ddlControlType.Enabled = false; } else { //新增方案 } //绑定字段类型 //BindFieldTypeView(fieldItem.FieldType); EffectDB EffectDB = Setting_EffectDB; divGroup.Visible = EffectDB.Group; if (EffectDB.Group) { BindTreeGroups(fieldItem); } //增加权限用户 DotNetNuke.Security.Roles.RoleController rc = new DotNetNuke.Security.Roles.RoleController(); WebHelper.BindList(cblPermissionsRoles, rc.GetPortalRoles(PortalId), "RoleName", "RoleName"); WebHelper.SelectedListMultiByValue(cblPermissionsRoles, fieldItem.Per_Roles); cbPermissionsAllUsers.Checked = fieldItem.Per_AllUsers == 0 ? true : false; WebHelper.BindList(ddlControlType, typeof(EnumViewControlType)); WebHelper.SelectedListByValue(ddlControlType, fieldItem.FieldType); WebHelper.BindList(ddlVerification, typeof(EnumVerification)); WebHelper.SelectedListByValue(ddlVerification, fieldItem.Verification); WebHelper.BindList(rblFTDirection, typeof(EnumControlDirection)); WebHelper.SelectedListByValue(rblFTDirection, fieldItem.Direction); List <DNNGo_PowerForms_Field> FieldControls = DNNGo_PowerForms_Field.FindAllByModuleId(ModuleId); WebHelper.BindList <DNNGo_PowerForms_Field>(ddlFTEqualsControl, FieldControls, "Name", "ID"); WebHelper.BindItem(ddlFTEqualsControl, ViewResourceText("lblDDRSelect", "==Please select=="), "0"); WebHelper.SelectedListByValue(ddlFTEqualsControl, fieldItem.EqualsControl); WebHelper.BindList <DNNGo_PowerForms_Field>(ddlFTAssociatedControl, FieldControls.FindAll(r => r.FieldType == (Int32)EnumViewControlType.DropDownList_Country), "Name", "ID"); WebHelper.BindItem(ddlFTAssociatedControl, ViewResourceText("lblDDRSelect", "==Please select=="), "0"); WebHelper.SelectedListByValue(ddlFTAssociatedControl, fieldItem.AssociatedControl); txtName.Text = fieldItem.Name; txtDescription.Text = fieldItem.Description; txtAlias.Text = fieldItem.Alias; txtToolTip.Text = fieldItem.ToolTip; txtFTDefaultValue.Text = fieldItem.DefaultValue; txtTinymceDefaultValue.Text = fieldItem.DefaultValue; txtFTListCollection.Text = fieldItem.FiledList; txtFTRows.Text = fieldItem.Rows.ToString(); WebHelper.SelectedListByValue(rblFTDirection, fieldItem.Direction); txtFTListColumn.Text = fieldItem.ListColumn.ToString(); txtFTInputLength.Text = fieldItem.InputLength.ToString(); txtFTWidth.Text = fieldItem.Width.ToString(); WebHelper.BindList(ddlFTWidth, typeof(EnumWidthSuffix)); WebHelper.SelectedListByValue(ddlFTWidth, fieldItem.WidthSuffix); //文章状态 cbStatus.Checked = fieldItem.Status == (Int32)EnumStatus.Activation; //是否必填 cbRequired.Checked = fieldItem.Required == 1; //发布时间和结束时间 if (FieldID > 0 && fieldItem != null && fieldItem.ID > 0) { liStartDateTime.Text = fieldItem.StartTime.ToString("MM/dd/yyyy hh:mm tt", new CultureInfo("en-US", false)); //Thread.CurrentThread.CurrentCulture liDisableDateTime.Text = fieldItem.EndTime.ToString("MM/dd/yyyy hh:mm tt", new CultureInfo("en-US", false)); //Thread.CurrentThread.CurrentCulture } txtStartDate.Text = fieldItem.StartTime.ToString("MM/dd/yyyy", new CultureInfo("en-US", false)); txtStartTime.Text = fieldItem.StartTime.ToString("hh:mm tt", new CultureInfo("en-US", false)); txtDisableDate.Text = fieldItem.EndTime.ToString("MM/dd/yyyy", new CultureInfo("en-US", false)); txtDisableTime.Text = fieldItem.EndTime.ToString("hh:mm tt", new CultureInfo("en-US", false)); }