// ************************************************************** // Create the hidden field to store the current request ticket private void SaveRefreshState() { int ticket = ConvertUtility.ToInt32(HttpContext.Current.Items[RefreshAction.NextPageTicketEntry]); ClientScript.RegisterHiddenField(RefreshAction.CurrentRefreshTicketEntry, ticket.ToString()); }
/// <summary> /// 保持页面滚动条的位置 /// </summary> protected void SetKeepScrollPosition() { StringBuilder saveScrollPosition = new StringBuilder(); StringBuilder setScrollPosition = new StringBuilder(); ClientScript.RegisterHiddenField("__SCROLLPOS", "0"); saveScrollPosition.Append("<script language='javascript'>"); saveScrollPosition.Append("function saveScrollPosition() {"); saveScrollPosition.Append(" document.forms[0].__SCROLLPOS.value = document.body.scrollTop;"); saveScrollPosition.Append("}"); saveScrollPosition.Append("document.body.onscroll=saveScrollPosition;"); saveScrollPosition.Append("</script>"); ClientScript.RegisterStartupScript(this.GetType(), "saveScroll", saveScrollPosition.ToString()); if (IsPostBack) { setScrollPosition.Append("<script language='javascript'>"); setScrollPosition.Append("function setScrollPosition() {"); setScrollPosition.Append(" document.body.scrollTop = " + Request["__SCROLLPOS"] + ";"); setScrollPosition.Append("}"); setScrollPosition.Append("document.body.onload=setScrollPosition;"); setScrollPosition.Append("</script>"); ClientScript.RegisterStartupScript(this.GetType(), "setScroll", setScrollPosition.ToString()); } }
protected void Page_Load(object sender, EventArgs e) { txt_emailid.Attributes.Add("onkeypress", "return controlEnter('" + btn_login.ClientID + "', event)"); txt_pwd.Attributes.Add("onkeypress", "return controlEnter('" + btn_login.ClientID + "', event)"); txt_emailid2.Attributes.Add("onkeypress", "return controlEnter('" + btn_register.ClientID + "', event)"); txt_pwd2.Attributes.Add("onkeypress", "return controlEnter('" + btn_register.ClientID + "', event)"); txt_confirmpwd2.Attributes.Add("onkeypress", "return controlEnter('" + btn_register.ClientID + "', event)"); if (!IsPostBack) { if (Session["CartPicks"] != null) { CartDetails = new List <CartItems>(); CartDetails = (List <CartItems>)Session["CartPicks"]; LoadItems(CartDetails); } else { Response.Redirect("../homepage.aspx"); } } if (IsPostBack) { if (adrFlag == true) { ClientScript.RegisterHiddenField("isPostBack", "1"); } } (Master.FindControl("cart1") as MainCartControl).Visible = false; }
/// <summary> /// 更新标识,正常提交都删除该次提交的时间,并生产当前新的时间 /// </summary> private void UpdateRefreshFlag() { #region Cookie模式 //注册页面唯一标识并返回 string pageGuid = SetCurPageGuid(); HttpCookie cookie = GetRefreshTicket(); if (cookie.Values.Count > 0) { cookie.Values.Remove(pageGuid); log.Debug("当前清除的cookie变是:" + pageGuid); } string submitTime = DateTime.Now.ToString("hhmmss.fffff"); //当前提交时间保存到隐藏域 ClientScript.RegisterHiddenField(HIDDEN_FIELD_NAME, submitTime); log.Debug("即将要新增的时间:submitTime:" + submitTime + " Guid:" + pageGuid.ToString()); cookie.Values.Add(pageGuid, submitTime); log.Debug("UpdateRefreshFlag中当前Cookie中存在的记录数为:" + cookie.Values.Count); for (int i = 0; i < cookie.Values.Count; i++) { log.Info("cookie[" + cookie.Values.GetKey(i) + "]:" + cookie.Values[i]); } Response.AppendCookie(cookie); #endregion }
protected override void SavePageStateToPersistenceMedium(object viewState) { Guid viewStateGuid; HtmlInputHidden control; byte[] viewStateArray = null; if (this.IsDesignMode) { return; } viewStateGuid = this.GetViewStateGuid(); using (MemoryStream stream = new MemoryStream()) { this.GetLosFormatter().Serialize(stream, viewState); viewStateArray = stream.ToArray(); } ViewStateSql obj = new ViewStateSql(viewStateGuid, viewStateArray, Artexacta.App.Configuration.Configuration.GetViewStateExpirationForDataBase()); ViewStateSqlBLL.Insert(obj); control = this.FindControl("__VIEWSTATEGUID") as HtmlInputHidden; if (control == null) { ClientScript.RegisterHiddenField("__VIEWSTATEGUID", viewStateGuid.ToString()); } else { control.Value = viewStateGuid.ToString(); } }
protected void Page_Load(object sender, EventArgs e) { HttpCookie clientCookie = Request.Cookies.Get(Constants.COOKIE_UTYPE); HttpCookie utypeCookie = Request.Cookies[Constants.COOKIE_UID]; if (clientCookie == null || utypeCookie == null) { Response.Redirect("../Default"); } if (!clientCookie.Value.Equals(Constants.REGULAR_TYPE)) { LogoutButton_Click(sender, e); } decimal id = Decimal.Parse(utypeCookie.Value); using (var db = new ds_assign1Entities()) { AppUser = db.APPLICATIONUSERs.Find(id); } if (AppUser == null) { LogoutButton_Click(sender, e); } Page.DataBind(); ClientScript.RegisterHiddenField("latitude", AppUser.LATITUDE); ClientScript.RegisterHiddenField("longitude", AppUser.LONGITUDE); }
protected override void SavePageStateToPersistenceMedium(Object viewState) { var compress = ConfigurationManager.AppSettings["PageSettings:CompressViewState"]; compress = (compress ?? String.Empty).ToLower(); if (compress != "lz" && compress != "def") { base.SavePageStateToPersistenceMedium(viewState); return; } using (var writer = new StringWriter()) { var formatter = new LosFormatter(); formatter.Serialize(writer, viewState); var viewStateString = writer.ToString(); var bytes = Convert.FromBase64String(viewStateString); switch (compress.ToLower()) { case "lz": bytes = bytes.CompressLZ(); break; case "def": bytes = bytes.CompressDef(); break; } ClientScript.RegisterHiddenField("__VSTATE", Convert.ToBase64String(bytes)); } }
/// <summary>重写保存页的所有视图状态信息</summary> /// <param name="state">要在其中存储视图状态信息的对象</param> protected override void SavePageStateToPersistenceMedium(Object state) { if (!CompressViewState) { base.SavePageStateToPersistenceMedium(state); return; } MemoryStream ms = new MemoryStream(); new LosFormatter().Serialize(ms, state); String vs = null; //判断序列化对象的字符串长度是否超出定义的长度界限 if (ms.Length > LimitLength) { MemoryStream ms2 = new MemoryStream(); // 必须移到第一位,否则后面读不到数据 ms.Position = 0; IOHelper.Compress(ms, ms2); vs = "1$" + Convert.ToBase64String(ms2.ToArray()); } else { vs = Convert.ToBase64String(ms.ToArray()); } //注册在页面储存ViewState状态的隐藏文本框,并将内容写入这个文本框 ClientScript.RegisterHiddenField("__VSTATE", vs); }
protected override void SavePageStateToPersistenceMedium(object viewState) { string str = "VIEWSTATE#" + Request.UserHostAddress + "#" + DateTime.Now.Ticks.ToString(); // Generar una clave única para este viewstate Cache.Add(str, viewState, null, DateTime.Now.AddMinutes(Session.Timeout), TimeSpan.Zero, System.Web.Caching.CacheItemPriority.Default, null); // Guardar el viewstate en el caché. ClientScript.RegisterHiddenField("__VIEWSTATE_CLAVE", str); }
protected void Page_Load(object sender, EventArgs e) { Form.SubmitDisabledControls = true; this.txtEndDate.Attributes.Add("readonly", "readonly"); ClientScript.RegisterHiddenField("h_EndDate", this.txtEndDate.ClientID.ToString()); ClientScript.RegisterHiddenField("h_ClientHistory", this.lstClientHistory.ClientID.ToString()); this.imgRunReport.Attributes.Add("onclick", "javascript:return CheckBeforeRun();"); if (!Page.IsPostBack) { this.txtEndDate.Text = DateTime.Now.ToString("dd-MM-yyyy"); Label lblTitle = (Label)Master.FindControl("lblTitle"); if (lblTitle != null) { lblTitle.Text = ConfigurationManager.AppSettings["AppName"].ToString() + "Billing"; } Client client = new Client(ConfigurationManager.AppSettings["connstring"].ToString()); this.lstClient.DataSource = client.getClients(); this.lstClient.DataTextField = "ClientDesc"; this.lstClient.DataValueField = "ClientId"; this.lstClient.DataBind(); this.lstClient.Items.Insert(0, "-- Select Client --"); this.lstClient.SelectedIndex = 0; this.lstClientHistory.Items.Insert(0, "-- Current invoice --"); this.lstClientHistory.SelectedIndex = 0; } this.btnCreateInvoice.Attributes.Add("style", "visibility:hidden"); ClientScript.RegisterHiddenField("h_lstClient", this.lstClient.ClientID.ToString()); this.imgRunReport.Attributes.Add("onclick", "javascript:return CheckForClient();"); }
protected void Page_Load(object sender, EventArgs e) { // Enter means go ClientScript.RegisterHiddenField("__EVENTTARGET", btnSubmit.ClientID); if (!IsPostBack) { // Validation rules rngPort.MinimumValue = IPEndPoint.MinPort.ToString(); rngPort.MaximumValue = IPEndPoint.MaxPort.ToString(); rngCleanup.MinimumValue = SyslogConfiguration.MinRetentionPeriod.ToString(); rngCleanup.MaximumValue = SyslogConfiguration.MaxRetentionPeriod.ToString(); try { SharedData sd = ObtainSharedData(); txtPort.Text = sd.Port.ToString(); txtCleanup.Text = sd.RetentionPeriod.ToString(); lblResults.Text = string.Empty; pnlMain.Visible = true; } catch (Exception ex) { lblResults.Text = String.Format("Could not load configuration - check that the server process" + " is running and correctly configured<br>{0}", ex.Message); pnlMain.Visible = false; } } }
protected override void SavePageStateToPersistenceMedium(object viewState) { var formatter = new LosFormatter(); var writer = new StringWriter(); formatter.Serialize(writer, viewState); string viewStateString = writer.ToString(); byte[] originalState = Convert.FromBase64String(viewStateString); if (_enableCompression) { byte[] tmp = Compressor.Compress(originalState); //If size is really smaller than the original one after compression, the compressed array is preferable if (tmp.Length < originalState.Length) { var tmp2 = new byte[tmp.Length + 1]; System.Buffer.BlockCopy(tmp, 0, tmp2, 1, tmp.Length); tmp2[0] = 1; //Compressed. Save into the first byte originalState = tmp2; } else { var tmp2 = originalState; var tmp3 = new byte[originalState.Length + 1]; System.Buffer.BlockCopy(tmp2, 0, tmp3, 1, tmp2.Length); tmp3[0] = 0; //Not Compressed. Save into the first byte originalState = tmp3; } } ClientScript.RegisterHiddenField("__VSTATE", Convert.ToBase64String(originalState)); }
protected override void SavePageStateToPersistenceMedium(object state) { /* * StringBuilder sb = new StringBuilder(); * StringWriter swr = new StringWriter(sb); * * LosFormatter formatter = new LosFormatter(); * formatter.Serialize(swr, state); * swr.Close(); * * // Store the textual representation of ViewState in the * // database or elsewhere * // The serialized view state is available via sb.ToString () * this.Session[this.Request.Url.ToString()] = sb.ToString();*/ /************************************************************************/ Guid viewStateGuid; HtmlInputHidden control; if (this.IsDesignMode) { return; } if (!this.IsSqlViewStateEnabled) { base.SavePageStateToPersistenceMedium(state); return; } viewStateGuid = this.GetViewStateGuid(); using (MemoryStream stream = new MemoryStream()) { this.GetLosFormatter().Serialize(stream, state); using (SqlConnection connection = new SqlConnection(this._viewStateConnectionString)) { using (SqlCommand command = new SqlCommand("SetViewState", connection)) { command.CommandType = CommandType.StoredProcedure; command.Parameters.Add("@returnValue", SqlDbType.Int).Direction = ParameterDirection.ReturnValue; command.Parameters.Add("@viewStateId", SqlDbType.UniqueIdentifier).Value = viewStateGuid; command.Parameters.Add("@value", SqlDbType.Image).Value = stream.ToArray(); command.Parameters.Add("@timeout", SqlDbType.Int).Value = this._viewStateTimeout.TotalMinutes; connection.Open(); command.ExecuteNonQuery(); } connection.Close(); } } control = this.FindControl("__VIEWSTATEGUID") as HtmlInputHidden; //ClientScript.RegisterHiddenField() if (control == null) { ClientScript.RegisterHiddenField("__VIEWSTATEGUID", viewStateGuid.ToString()); } else { control.Value = viewStateGuid.ToString(); } /************************************************************************/ }
protected void Page_Load(object sender, EventArgs e) { ClientScript.RegisterHiddenField(DDL_THEMES_ID_KEY, ddlThemes.UniqueID); if (!IsPostBack) { VisualizeThemes(); } }
protected override void Render(System.Web.UI.HtmlTextWriter writer) { string str = GetSessinKey(); this.Session[str] = _strLastViewstate; ClientScript.RegisterHiddenField(_hiddenfieldName, _strSessionKey); base.Render(writer); }
protected void Page_Load(object sender, EventArgs e) { DialogUtils.SetScriptSubmit(this); ClientScript.RegisterHiddenField("resd", ""); perso = sc.UserAction(User.Identity.Name, Restrictions.Perso); branch_current = sc.BranchId(User.Identity.Name); branch_main_filial = BranchStore.getBranchMainFilial(branch_current, perso); if (sc.UserAction(User.Identity.Name, Restrictions.AllData)) { branchSearch = " (1=1) "; } else { branchSearch = String.Format(" (id_branchCard={0} or id_branchCard in (select id from Branchs where id_parent={0} or id_parentTr={0}))", sc.BranchId(User.Identity.Name)); } if (!sc.UserAction(User.Identity.Name, Restrictions.CardsView)) { Response.Redirect("~\\Account\\Restricted.aspx", true); } if (IsPostBack) { return; } lock (Database.lockObjectDB) { gvCard.PageSize = 50; // Решили оставить страницу с картами певоначально пустой lbSearch.Text = "where 1=0"; //if (ServiceClass.UserAction(User.Identity.Name, Restrictions.Filial)) // lbSearch.Text = " where id_stat=4 "; //else // lbSearch.Text = " where id_stat=2 "; lbSort.Text = "order by dateProd desc,DepBranchCard,company,fio"; Refr(true); } if (!sc.UserAction(User.Identity.Name, Restrictions.CardsDelete)) { bDeleteCards.Visible = false; } if (!sc.UserAction(User.Identity.Name, Restrictions.CardsGive)) { bFilCards.Visible = false; } GC.Collect(); Session["Card"] = this; }
void Page_PreRender(object sender, EventArgs e) { if (!IsPostBack) { SetActionStamp(); } ClientScript.RegisterHiddenField("actionStamp", Session["actionStamp"].ToString()); }
void Page_PreRender(object sender, EventArgs e) { StringBuilder bldr = new StringBuilder(); bldr.AppendFormat("var Timer = new myTimer({0},{1},'{2}','timerData');", this.timerStartValue, this.TimerInterval, this.lblTimerCount.ClientID); bldr.Append("Timer.go()"); ClientScript.RegisterStartupScript(this.GetType(), "TimerScript", bldr.ToString(), true); ClientScript.RegisterHiddenField("timerData", timerStartValue.ToString()); }
protected override void SavePageStateToPersistenceMedium(object state) { LosFormatter lf = new LosFormatter(); StringWriter sw = new StringWriter(); lf.Serialize(sw, state); byte[] b = Convert.FromBase64String(sw.ToString()); ClientScript.RegisterHiddenField("__VSTATE", Convert.ToBase64String(Compress(b))); }
SavePageStateToPersistenceMedium(object viewState) { MemoryStream ms = new MemoryStream(); _formatter.Serialize(ms, viewState); byte[] viewStateArray = ms.ToArray(); ClientScript.RegisterHiddenField("__COMPRESSEDVIEWSTATE", Convert.ToBase64String(CompressViewState.Compress(viewStateArray))); }
/// <summary> /// Saves any view and control state to appropriate viewstate provider. /// This method shields the client from viewstate key generation issues. /// </summary> /// <param name="viewState"></param> protected override void SavePageStateToPersistenceMedium(object viewState) { // Make up a unique name string random = _random.Next(0, int.MaxValue).ToString(); string name = "ACTION_" + random + "_" + Request.UserHostAddress + "_" + DateTime.Now.Ticks.ToString(); ViewStateProviderService.SavePageState(name, viewState); ClientScript.RegisterHiddenField("__VIEWSTATE_KEY", name); }
//非PostBack時將會動態產生隱藏欄位紀錄目前時間 void Page_PreRender(object sender, EventArgs e) { if (!IsPostBack) { // SetActionStamp(); SetActionStampCookie(); } //ClientScript.RegisterHiddenField("actionStamp", Session["actionStamp"].ToString()); ClientScript.RegisterHiddenField("actionStamp", HttpContext.Current.Request.Cookies["actionStamp"].Value); }
protected override void SavePageStateToPersistenceMedium(object viewState) { var ms = new MemoryStream(); _formatter.Serialize(ms, viewState); var viewStateBytes = ms.ToArray(); ClientScript.RegisterHiddenField(CompressedViewstateKey , Convert.ToBase64String(Compress(viewStateBytes))); }
private void UpdateGloablScript(int groupId) { if (!_hiddenFields.Contains(groupId)) { _hiddenFields.Add(groupId); _computeFieldsScript.Append(String.Format("ComputeHidden(\"{0}\");", groupId)); } ClientScript.RegisterHiddenField(String.Format("Hidden{0}", groupId), ""); }
protected void Page_Init(object sender, EventArgs e) { ClientScript.RegisterHiddenField("h_txtUserId", this.txtUserId.ClientID.ToString()); ClientScript.RegisterHiddenField("h_txtUserName", this.txtUserName.ClientID.ToString()); ClientScript.RegisterHiddenField("h_txtPassword", this.txtPassword.ClientID.ToString()); ClientScript.RegisterHiddenField("h_txtUserProfile", this.lstUserProfile.ClientID.ToString()); this.txtUserId.Attributes.Add("onclick", "javascript:document.getElementById(document.forms[0].h_txtUserName.value).focus();"); this.txtUserId.Attributes.Add("onfocus", "javascript:document.getElementById(document.forms[0].h_txtUserName.value).focus();"); this.LoadNavSubGrid(); }
private void Page_Load(object sender, System.EventArgs e) { // Put user code to initialize the page here // Hitting Enter in the text field should do "Search" - this works cross-browser this.TextBoxSearch.Attributes.Add( "onKeyPress", "if((event.keyCode||event.which)==13){document.getElementById('" + ButtonSearch.ClientID + "').click();return false;}"); // Make Search the default button ClientScript.RegisterHiddenField("__EVENTTARGET", ButtonSearch.ID); if (!this.IsPostBack) { // ViewState should be pay-for-play - it's enabled on first search Form1.EnableViewState = false; ViewState["x"] = -0.5; ViewState["y"] = -0.5; ViewState["scale"] = 1.0; ViewState["options"] = MapOptions.SectorGrid | MapOptions.SubsectorGrid | MapOptions.SectorsAll | MapOptions.BordersMajor | MapOptions.BordersMinor | MapOptions.NamesMajor | MapOptions.WorldsCapitals | MapOptions.WorldsHomeworlds; ViewState["style"] = "poster"; if (Request.Cookies["MobileMapSize"] != null) { string val = Request.Cookies["MobileMapSize"].Value; // back compat if (val == "Large") { val = "192"; } if (val == "Small") { val = "128"; } this.DropDownTileSize.SelectedValue = val; } else { this.DropDownTileSize.SelectedValue = LargeTileDimension.ToString(CultureInfo.InvariantCulture); } } int dim; Int32.TryParse(DropDownTileSize.SelectedValue, out dim); dim = Util.Clamp(dim, SmallTileDimension, MaxTileDimension); ViewState["w"] = dim; ViewState["h"] = dim; Refresh(); }
private void UpdateGloablScript(SPField field, string mode) { _computeFieldsScript.Append(String.Format("ComputeField(\"{0}{1}\");", field.InternalName, mode)); if (!_hiddenFields.ContainsKey(field.InternalName)) { _hiddenFields.Add(field.InternalName, new Dictionary <string, string>()); } _hiddenFields[field.InternalName].Add(mode, String.Format("Hidden{0}{1}", field.InternalName, mode)); ClientScript.RegisterHiddenField(String.Format("Hidden{0}{1}", field.InternalName, mode), ""); }
protected void Page_Load(object sender, EventArgs e) { ClientScript.RegisterHiddenField("resd", ""); lock (Database.lockObjectDB) { if (!IsPostBack) { lbInform.Text = ""; Refr(0); } } }
protected void Page_Load(object sender, EventArgs e) { if ((Request["__EVENTTARGET"] == null) || (Request["__EVENTTARGET"].ToString() != "lkbRecoverPassword")) { ClientScript.RegisterHiddenField("__EVENTTARGET", btnSignIn.ClientID); } else { ClientScript.RegisterHiddenField("__EVENTTARGET", txtEmail.ClientID); } DbControl.setDataBasePath(MapPath("data/db.mdb")); }
void BasePage_Load(object sender, EventArgs e) { if (!IsPostBack) { string culture = ""; if (Request.Params[PAGE_SELECT_CULTURE] != null) { culture = Request.Params[PAGE_SELECT_CULTURE].Trim(); } ClientScript.RegisterHiddenField(PAGE_SELECT_CULTURE, culture); } }