public static void SetFocus(System.Web.UI.Page page, System.Web.UI.Control ctrl) { string s = "<script language='javascript'>" + "document.getElementById('" + ctrl.ID + "').focus() </script>"; if (!page.IsStartupScriptRegistered("focus")) { page.RegisterStartupScript("focus", s); } }
public static void CreateMessageAlert(System.Web.UI.Page senderpage, string alertMsg, string alertKey) { string strScript; strScript = "<script language=JavaScript>alert('" + alertMsg + "')</script>"; if (!(senderpage.IsStartupScriptRegistered(alertKey))) { senderpage.RegisterStartupScript(alertKey, strScript); } }
public static void ShowIframe(System.Web.UI.Page objPage, string pageurl) { if (!objPage.IsStartupScriptRegistered(objPage.UniqueID + "MessageBox")) { StringBuilder str = new StringBuilder(); str.Append("<script language=\"JavaScript\">"); str.Append(" ShowIframeNotClose('" + pageurl + "')"); str.Append("</script>"); objPage.RegisterStartupScript(objPage.UniqueID + "MessageBox", str.ToString()); } }
/// <summary> /// 弹出提示,2秒后关闭 /// </summary> /// <param name="objPage"></param> /// <param name="strHints"></param> public static void ShowOK(System.Web.UI.Page objPage, string strHints) { if (!objPage.IsStartupScriptRegistered(objPage.UniqueID + "MessageBox")) { StringBuilder str = new StringBuilder(); str.Append("<script language=\"JavaScript\">"); str.Append(" layer.msg('" + strHints + "',2,9);"); str.Append("</script>"); objPage.RegisterStartupScript(objPage.UniqueID + "MessageBox", str.ToString()); } }
public static void ShowWrongAndClose(System.Web.UI.Page objPage, string strHints) { if (!objPage.IsStartupScriptRegistered(objPage.UniqueID + "MessageBox")) { StringBuilder str = new StringBuilder(); str.Append("<script language=\"JavaScript\">"); str.Append(" parent.layer.msg('" + strHints + "',2,8);"); str.Append("parent.layer.close(parent.layer.getFrameIndex(window.name));"); str.Append("</script>"); objPage.RegisterStartupScript(objPage.UniqueID + "MessageBox", str.ToString()); } }
public static void ShowOKAndReflash(System.Web.UI.Page objPage, string strHints, string ControlID) { if (!objPage.IsStartupScriptRegistered(objPage.UniqueID + "MessageBox")) { StringBuilder str = new StringBuilder(); str.Append("<script language=\"JavaScript\">"); str.Append("setTimeout(function(){$('#" + ControlID + "', window.document).click();},2000);"); str.Append("layer.msg('" + strHints + "',2,9);"); //str.Append("parent.layer.close(parent.layer.getFrameIndex(window.name));"); str.Append("</script>"); objPage.RegisterStartupScript(objPage.UniqueID + "MessageBox", str.ToString()); } }
public static void ShowOKAndRedirect(System.Web.UI.Page objPage, string strHints, string PageUrl) { if (!objPage.IsStartupScriptRegistered(objPage.UniqueID + "MessageBox")) { StringBuilder str = new StringBuilder(); str.Append("<script language=\"JavaScript\">"); str.Append("setTimeout(function(){ window.location.href='" + PageUrl + "'},2000);"); str.Append(" layer.msg('" + strHints + "',2,9);"); //str.Append("parent.layer.close(parent.layer.getFrameIndex(window.name));"); str.Append("</script>"); objPage.RegisterStartupScript(objPage.UniqueID + "MessageBox", str.ToString()); } }
public static string[][] InitKeywordTitleDes(System.Web.UI.Page page, long infoID, Tz888.Model.Info.MainInfoModel model, CheckBoxList chkKeyWord, CheckBoxList chkTitles, CheckBoxList chkDes, ref string defaultValueID) { bool isPostback = page.IsPostBack;//初始化时需要判断是否是PostBack ArrayList disableInputs = new ArrayList(); PageIniControl pic = new PageIniControl(); //注册ajax脚本 if (page.IsClientScriptBlockRegistered("ajaxInvokeadfsf") == false) { page.RegisterClientScriptBlock("ajaxInvokeadfsf", ajaxInvoke); } DataTable dt = null; if (isPostback == false) // || defaultValueID == null || defaultValueID == "" || defaultValueID == "0" ) { dt = pic.DefaultViewDataBind(model).Table; //Load对应信息类型的关键字等设置 if (dt != null && dt.Rows.Count > 0) { defaultValueID = dt.Rows[0]["ID"].ToString(); } else { return(new string[][] { new string[] {}, new string[] {}, new string[] {} }); } } else { if (defaultValueID == null || defaultValueID == "" || defaultValueID == "0") { return(new string[][] { new string[] {}, new string[] {}, new string[] {} }); //返回空串 } long currentPage = 1; long pageCount = 0; Tz888.BLL.Info.SetSubDefaultValueRule ssdv = new SetSubDefaultValueRule(); dt = (ssdv.GetList("ID as SubDefaultID,DefType,IsNeeded,IsDefaultSelect", "SetDefaultValueID=" + defaultValueID, "", ref currentPage, -1, ref pageCount)).Table; } bool isFirst = true;//这条信息第一次加载 //Load该信息的关键字等设置 Tz888.BLL.Info.InfoDefaultDEFRule infoDefault = new InfoDefaultDEFRule(); DataView dvInfoDefault = infoDefault.GetList(infoID, 0); DataView dvKeyWord = new DataView(dt); if (isPostback == false) { dvKeyWord.Sort = "Seq"; dvKeyWord.RowFilter = "DefType=2 OR DefType=3 OR DefType=6 OR DefType=7"; chkKeyWord.DataSource = dvKeyWord; chkKeyWord.DataBind(); //该信息的定义 dvInfoDefault.RowFilter = "DefType = 2"; for (int i = 0; i < dvInfoDefault.Count; i++) { string subDefaultValueID = dvInfoDefault[i]["SubDefaultValueID"].ToString().Trim(); ListItem li = chkKeyWord.Items.FindByValue(subDefaultValueID); if (li != null) { li.Selected = true; isFirst = false; } } } ArrayList keyDefaults = new ArrayList();//默认选择和必填项,ID的集合 //默认选择 for (int i = 0; i < dvKeyWord.Count; i++) { bool isDefaultSelect = Convert.ToBoolean(dvKeyWord[i]["IsDefaultSelect"]); bool isNeeded = Convert.ToBoolean(dvKeyWord[i]["IsNeeded"]); string subDefaultID = dvKeyWord[i]["SubDefaultID"].ToString().Trim(); if (isDefaultSelect || isNeeded) { keyDefaults.Add(subDefaultID); } if ((isDefaultSelect && isFirst) || isNeeded) { ListItem li = chkKeyWord.Items.FindByValue(subDefaultID); if (li != null) { if (isPostback == false) { li.Selected = true; } if (isNeeded) { disableInputs.Add(chkKeyWord.ClientID + "_" + chkKeyWord.Items.IndexOf(li).ToString()); } } } } dvKeyWord = null; //绑定Title isFirst = true; //这条信息第一次加载 ArrayList titleDefaults = new ArrayList(); //默认选择和必填项,ID的集合 DataView dvTitle = new DataView(dt); if (isPostback == false) { dvTitle.Sort = "Seq"; dvTitle.RowFilter = "DefType=1 OR DefType=3 OR DefType=5 OR DefType=7"; chkTitles.DataSource = dvTitle; chkTitles.DataBind(); dvInfoDefault.RowFilter = "DefType = 1"; for (int i = 0; i < dvInfoDefault.Count; i++) { string subDefaultValueID = dvInfoDefault[i]["SubDefaultValueID"].ToString().Trim(); ListItem li = chkTitles.Items.FindByValue(subDefaultValueID); if (li != null) { li.Selected = true; isFirst = false; } } } //默认选择 for (int i = 0; i < dvTitle.Count; i++) { bool isDefaultSelect = Convert.ToBoolean(dvTitle[i]["IsDefaultSelect"]); bool isNeeded = Convert.ToBoolean(dvTitle[i]["IsNeeded"]); string subDefaultID = dvTitle[i]["SubDefaultID"].ToString().Trim(); if (isDefaultSelect || isNeeded) { titleDefaults.Add(subDefaultID); } if ((isDefaultSelect && isFirst) || isNeeded) { ListItem li = chkTitles.Items.FindByValue(subDefaultID); if (li != null) { if (isPostback == false) { li.Selected = true; } if (isNeeded) { disableInputs.Add(chkTitles.ClientID + "_" + chkTitles.Items.IndexOf(li).ToString()); } } } } dvTitle = null; //绑定描述 isFirst = true;//这条信息第一次加载 DataView dvDes = new DataView(dt); if (isPostback == false) { dvDes.Sort = "Seq"; dvDes.RowFilter = "DefType=4 OR DefType=5 OR DefType=6 OR DefType=7"; chkDes.DataSource = dvDes; chkDes.DataBind(); dvInfoDefault.RowFilter = "DefType = 4"; for (int i = 0; i < dvInfoDefault.Count; i++) { string subDefaultValueID = dvInfoDefault[i]["SubDefaultValueID"].ToString().Trim(); ListItem li = chkDes.Items.FindByValue(subDefaultValueID); if (li != null) { li.Selected = true; isFirst = false; } } } //默认选择 ArrayList desDefaults = new ArrayList();//默认选择和必填项,ID的集合 for (int i = 0; i < dvDes.Count; i++) { bool isDefaultSelect = Convert.ToBoolean(dvDes[i]["IsDefaultSelect"]); bool isNeeded = Convert.ToBoolean(dvDes[i]["IsNeeded"]); string subDefaultID = dvDes[i]["SubDefaultID"].ToString().Trim(); if (isDefaultSelect || isNeeded) { desDefaults.Add(subDefaultID); } if ((isDefaultSelect && isFirst) || isNeeded) { ListItem li = chkDes.Items.FindByValue(subDefaultID); if (li != null) { if (isPostback == false) { li.Selected = true; } if (isNeeded) { disableInputs.Add(chkDes.ClientID + "_" + chkDes.Items.IndexOf(li).ToString()); } } } } dvDes = null; string disableInputStr = ""; for (int i = 0; i < disableInputs.Count; i++) { disableInputStr += @"'" + disableInputs[i].ToString() + @"',"; } if (disableInputStr != "")//注册禁用必选项的脚本 { disableInputStr = disableInputStr.TrimEnd(new char[] { ',' }); if (page.IsStartupScriptRegistered("DisabledScript") == false) { page.RegisterStartupScript("DisabledScritp", string.Format(DisableScript, disableInputStr)); } } string[][] allDefaults = new string[3][]; allDefaults[0] = new string[keyDefaults.Count]; allDefaults[1] = new string[titleDefaults.Count]; allDefaults[2] = new string[desDefaults.Count]; keyDefaults.CopyTo(allDefaults[0]); titleDefaults.CopyTo(allDefaults[1]); desDefaults.CopyTo(allDefaults[2]); return(allDefaults); }