protected override void OnPreRender(EventArgs e) { base.OnPreRender(e); #region Used to maintain scroll position in gridview string js; ClientScriptManager sm = Page.ClientScript; if (!sm.IsOnSubmitStatementRegistered(this.GetType(), "SaveScrollPosition")) { js = "var hfScrollPos = document.getElementById('" + hidScrollPosition.ClientID + "');\n\r"; js += "var gridPanel = document.getElementById('" + gridPanel.ClientID + "');\n\r"; js += "hfScrollPos.value = gridPanel.scrollTop;\n\r"; sm.RegisterOnSubmitStatement(this.GetType(), "SaveScrollPosition", js); } if (_maintainScrollPos) { if (!sm.IsStartupScriptRegistered(this.GetType(), "RetrieveScrollPosition")) { js = "var hfScrollPos = document.getElementById('" + hidScrollPosition.ClientID + "');\n\r"; js += "var gridPanel = document.getElementById('" + gridPanel.ClientID + "');\n\r"; js += "if ( hfScrollPos.value != '' )\n\r"; js += "{\n\r"; js += " gridPanel.scrollTop = hfScrollPos.value;\n\r"; js += "}\n\r"; sm.RegisterStartupScript(this.GetType(), "RetrieveScrollPosition", js, true); } } #endregion }
protected override void OnPreRender(EventArgs e) { // Call base base.OnPreRender(e); // See if we're enabled if (Enabled) { // Generate the list of split field names List <String> splitFieldNames = new List <string>(); foreach (RepeaterItem splitLine in discoveryShipmentLines.Items) { // Find the quantity control TextBox splitQuantity = splitLine.FindControl("txtSplitQuantity") as TextBox; Debug.Assert(null != splitQuantity); // Add it's name to the list splitFieldNames.Add(splitQuantity.ClientID); } // Make sure that we have some lines if (splitFieldNames.Count > 0) { // String builder for client script StringBuilder sbClientScript = new StringBuilder(); // Add resetNumericFields javascript to the cancel client click sbClientScript.Append("resetNumericFields(0"); foreach (String splitFieldName in splitFieldNames) { sbClientScript.AppendFormat(", {0}", splitFieldName); } sbClientScript.Append(");"); // Clear values on cancel btnSplitCancel.OnClientClick = sbClientScript.ToString(); // Disable split button when submitted String csName = "SplitShipmentOnSubmitScript" + this.ClientID; Type csType = this.GetType(); // Get a ClientScriptManager reference from the Page class. ClientScriptManager cs = Page.ClientScript; // Check to see if the OnSubmit statement is already registered. if (!cs.IsOnSubmitStatementRegistered(csType, csName)) { // Disable the split button once clicked //cs.RegisterOnSubmitStatement(csType, csName, String.Format("if (null == theForm.{0}) return true; if (typeof(ValidatorOnSubmit) == 'function' && ValidatorOnSubmit() == false) return false; theForm.{0}.disabled = true;", btnSplitConfirm.ClientID)); } // Enable split button from main split button //btnSplitShipment.OnClientClick = String.Format("{0}.disabled = false;", btnSplitConfirm.ClientID); } } // Enable/disable btnSplitShipment.Visible = this.Enabled && DiscoveryPage.HasRule("Shipment: Split Orders", Context.User); }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); String csname = "OnSubmitScript"; Type cstype = this.GetType(); ClientScriptManager cs = Page.ClientScript; // Check to see if the OnSubmit statement is already registered. if (!cs.IsOnSubmitStatementRegistered(cstype, csname)) { String cstext = "return FormCheck_OnSubmit();"; cs.RegisterOnSubmitStatement(cstype, csname, cstext); } }
/// <summary> /// Registers the client script. /// </summary> private void RegisterClientScript() { ClientScriptManager csm = this.Page.ClientScript; string callbackFunction = csm.GetCallbackEventReference(this, String.Format("document.getElementById('{0}').value", this.job.ClientID), "__progressBarCallback", "'" + this.bar.ClientID + "'", true); csm.RegisterArrayDeclaration("__progressBarInstances", String.Format("new __progressBarInstance('{0}', \"{1}\", {2})", this.bar.ClientID, callbackFunction, this.RefreshInterval)); // Register the initialize progress bar script. string initScriptKey = this.GetType().Name; if (!csm.IsStartupScriptRegistered(initScriptKey)) { string initScript = "__progressBarInit(__progressBarInstances);"; csm.RegisterStartupScript(this.GetType(), initScriptKey, initScript, true); } csm.RegisterClientScriptResource(this.GetType(), "Wilco.Web.Resources.ProgressBar.js"); if (this.AutoStart) { string autoStartScriptKey = "__progressBarAutoStart" + this.ClientID; if (!csm.IsStartupScriptRegistered(this.GetType(), autoStartScriptKey)) { string script = String.Format("__progressBarEnqueue('{0}');", this.bar.ClientID); csm.RegisterStartupScript(this.GetType(), autoStartScriptKey, script, true); } } if (this.startOnSubmit) { string submitScriptKey = "__progressBarOnSubmit" + this.ClientID; if (!csm.IsOnSubmitStatementRegistered(this.GetType(), submitScriptKey)) { string script = String.Format("__progressBarEnqueue('{0}');", this.bar.ClientID); csm.RegisterOnSubmitStatement(this.GetType(), submitScriptKey, script); } } else { WebControl control = (WebControl)this.processStarterControl; control.Attributes["onclick"] += callbackFunction + ";"; } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { stBreadcrumb.Visible = (SiteMap.CurrentNode != SiteMap.RootNode); } Page.Header.DataBind(); String csname = "OnSubmitScript"; Type cstype = this.GetType(); ClientScriptManager cs = Page.ClientScript; if (!cs.IsOnSubmitStatementRegistered(cstype, csname)) { String cstext = "g_isPostBack = true;"; cs.RegisterOnSubmitStatement(cstype, csname, cstext); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { string script = "$(document).ready(function () { $('[id*=btnSubmit]').click(); });"; Page.ClientScript.RegisterStartupScript(this.GetType(), "load", script, true); stBreadcrumb.Visible = (SiteMap.CurrentNode != SiteMap.RootNode); } Page.Header.DataBind(); String csname = "OnSubmitScript"; Type cstype = this.GetType(); ClientScriptManager cs = Page.ClientScript; if (!cs.IsOnSubmitStatementRegistered(cstype, csname)) { String cstext = "g_isPostBack = true;"; cs.RegisterOnSubmitStatement(cstype, csname, cstext); } }
/// <summary> /// Determines whether the OnSubmit statement is registered with the <see cref="T:System.Web.UI.Page"/> object using the specified key. /// </summary> /// <returns> /// true if the OnSubmit statement is registered; otherwise, false. /// </returns> /// <param name="key">The key of the OnSubmit statement to search for. /// </param> public bool IsOnSubmitStatementRegistered(string key) { return(_clientScriptManager.IsOnSubmitStatementRegistered(key)); }