예제 #1
0
        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
        }
예제 #2
0
        public void ClientScriptManager_RegisterOnSubmitStatementException()
        {
            Page   p               = new Page();
            String csname          = "OnSubmitScript";
            ClientScriptManager cs = p.ClientScript;
            String cstext          = "document.write('Text from OnSubmit statement');";

            cs.RegisterOnSubmitStatement(null, csname, cstext);
        }
예제 #3
0
        public static void RegisterOnSubmitStatement(Page p)
        {
            String csname          = "OnSubmitScript";
            Type   cstype          = p.GetType();
            ClientScriptManager cs = p.ClientScript;
            String cstext          = "document.write('Text from OnSubmit statement');";

            cs.RegisterOnSubmitStatement(cstype, csname, cstext);
        }
예제 #4
0
        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);
            }
        }
예제 #5
0
        /// <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 + ";";
            }
        }
예제 #6
0
        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);
            }
        }
예제 #7
0
        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>
 /// Registers an OnSubmit statement with the <see cref="T:System.Web.UI.Page"/> object using a type, a key, and a script literal. The statement executes when the <see cref="T:System.Web.UI.HtmlControls.HtmlForm"/> is submitted.
 /// </summary>
 /// <param name="type">The type of the OnSubmit statement to register.
 /// </param><param name="key">The key of the OnSubmit statement to register.
 /// </param><param name="script">The script literal of the OnSubmit statement to register.
 /// </param><exception cref="T:System.ArgumentNullException"><paramref name="type"/> is null.
 /// </exception>
 public void RegisterOnSubmitStatement(Type type, string key, string script)
 {
     _clientScriptManager.RegisterOnSubmitStatement(type, key, script);
 }