Example #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            HtmlTable     table  = new HtmlTable();
            HtmlTableRow  trow   = new HtmlTableRow();
            HtmlTableCell tcell  = new HtmlTableCell();
            TextBox       txtbox = new TextBox();

            txtbox.ID   = "txtbox";
            txtbox.Text = "Mohit";
            tcell.Controls.Add(txtbox);
            trow.Controls.Add(tcell);
            table.Controls.Add(trow);


            trow  = new HtmlTableRow();
            tcell = new HtmlTableCell();
            Button btnclick = new Button();

            btnclick.ID   = "btnClick";
            btnclick.Text = "Click Me";
            ClientScriptManager cs = Page.ClientScript;

            btnclick.Attributes.Add("onclick", "" + cs.GetPostBackEventReference(this, btnclick.ID) + ";return false;");
            tcell.Controls.Add(btnclick);
            trow.Controls.Add(tcell);
            table.Controls.Add(trow);

            PlaceHolder.Controls.Add(table);
        }
Example #2
0
        public static string GetPostBackReference([NotNull] this Control thisValue, string argOrNullForLaterFormat, bool registerForEventValidation)
        {
            Page page = thisValue.AsPage();
            ClientScriptManager cs = page.ClientScript;

            return(cs.GetPostBackEventReference(thisValue, argOrNullForLaterFormat ?? "{0}", registerForEventValidation));
        }
Example #3
0
        protected override void RenderAttributes(HtmlTextWriter writer)
        {
#if NET_2_0
            CultureInfo inv        = Helpers.InvariantCulture;
            string      input_type = Type;
            if (0 != String.Compare(input_type, "reset", true, inv) &&
                ((0 == String.Compare(input_type, "submit", true, inv)) ||
                 (0 == String.Compare(input_type, "button", true, inv) && Events [ServerClickEvent] != null)))
            {
                string onclick = String.Empty;
                if (Attributes ["onclick"] != null)
                {
                    onclick = ClientScriptManager.EnsureEndsWithSemicolon(Attributes ["onclick"] + onclick);
                    Attributes.Remove("onclick");
                }
                if (Page != null)
                {
                    PostBackOptions options = GetPostBackOptions();
                    onclick += Page.ClientScript.GetPostBackEventReference(options, true);
                }

                if (onclick.Length > 0)
                {
                    writer.WriteAttribute("onclick", onclick, true);
                    writer.WriteAttribute("language", "javascript");
                }
            }
#else
            if (RenderOnClick())
            {
                string oc = null;
                ClientScriptManager csm = new ClientScriptManager(Page);
                if (Page.AreValidatorsUplevel())
                {
                    oc = csm.GetClientValidationEvent();
                }
                else if (Events [ServerClickEvent] != null)
                {
                    oc = Attributes ["onclick"] + " " + csm.GetPostBackEventReference(this, "");
                }

                if (oc != null)
                {
                    writer.WriteAttribute("language", "javascript");
                    writer.WriteAttribute("onclick", oc, true);
                }
            }
#endif

            Attributes.Remove("CausesValidation");
#if NET_2_0
            // LAMESPEC: MS doesn't actually remove this
            //attribute.  it shows up in the rendered
            //output.

            // Attributes.Remove("ValidationGroup");
#endif
            base.RenderAttributes(writer);
        }
Example #4
0
 public static void ButtonPreventDoubleClick(Button btn, ClientScriptManager csm)
 {
     try
     {
         btn.Attributes["onclick"] = "this.disabled = 'disabled';" + csm.GetPostBackEventReference(btn, "") + ";";
     }
     catch { }
 }
Example #5
0
        public void ClientScriptManager_GetPostBackEventReference_2()
        {
            MyPage p = new MyPage();
            ClientScriptManager cs = p.ClientScript;
            String result          = cs.GetPostBackEventReference(p, "args1");

            Assert.IsTrue(result.IndexOf(p.ClientID) != -1, "GetPostBackEventReference#2_targetEvent");
            Assert.IsTrue(result.IndexOf("args1") != -1, "GetPostBackEventReference#2_targetArgs");
        }
Example #6
0
 public static void AddAttributesToGridDataBound(ClientScriptManager manager, GridView grid, GridViewRowEventArgs e)
 {
     if (e.Row.RowType != DataControlRowType.DataRow)
     {
         return;
     }
     e.Row.Attributes["onmouseover"] = "this.style.cursor='pointer';this.style.textDecoration='underline';";
     e.Row.Attributes["onmouseout"]  = "this.style.textDecoration='none';";
     e.Row.Attributes["onclick"]     = manager.GetPostBackEventReference(grid, "Select$" + e.Row.RowIndex);
 }
Example #7
0
        public static string GetPostBackReference([NotNull] this Control thisValue, PostBackOptions options, bool registerForEventValidation)
        {
            if (options == null)
            {
                return(GetPostBackReference(thisValue, string.Empty, registerForEventValidation));
            }
            Page page = thisValue.AsPage();
            ClientScriptManager cs = page.ClientScript;

            options.Argument ??= "{0}";
            return(cs.GetPostBackEventReference(options, registerForEventValidation));
        }
Example #8
0
        protected override void AddAttributesToRender(HtmlTextWriter w)
        {
            Page page = Page;

            if (page != null)
            {
                page.VerifyRenderingInServerForm(this);
            }

            bool enabled = IsEnabled;

#if NET_2_0
            string onclick = OnClientClick;
            onclick = ClientScriptManager.EnsureEndsWithSemicolon(onclick);
            if (HasAttributes && Attributes ["onclick"] != null)
            {
                onclick = ClientScriptManager.EnsureEndsWithSemicolon(onclick + Attributes ["onclick"]);
                Attributes.Remove("onclick");
            }

            if (onclick.Length > 0)
            {
                w.AddAttribute(HtmlTextWriterAttribute.Onclick, onclick);
            }

            if (enabled && page != null)
            {
                PostBackOptions options = GetPostBackOptions();
                string          href    = page.ClientScript.GetPostBackEventReference(options, true);
                w.AddAttribute(HtmlTextWriterAttribute.Href, href);
            }
            base.AddAttributesToRender(w);
            AddDisplayStyleAttribute(w);
#else
            base.AddAttributesToRender(w);
            if (page == null || !enabled)
            {
                return;
            }

            if (CausesValidation && page.AreValidatorsUplevel())
            {
                ClientScriptManager csm = new ClientScriptManager(page);
                w.AddAttribute(HtmlTextWriterAttribute.Href,
                               String.Concat("javascript:{if (typeof(Page_ClientValidate) == 'function') Page_ClientValidate(); ",
                                             csm.GetPostBackEventReference(this, String.Empty), ";}"));
            }
            else
            {
                w.AddAttribute(HtmlTextWriterAttribute.Href, page.ClientScript.GetPostBackClientHyperlink(this, String.Empty));
            }
#endif
        }
Example #9
0
        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);

            //if (!this.DesignMode & !Page.IsPostBack)
            if (!this.DesignMode)
            {
                ClientScriptManager cm = this.Page.ClientScript;

                if (!cm.IsClientScriptBlockRegistered("CallServer"))
                {
//                    String callbackReference = cm.GetCallbackEventReference(this, "arg", "ReceiveServerData", "", true);
                    String callbackReference = cm.GetCallbackEventReference(this, "arg", "ReceiveServerData", "''", true);
                    callbackReference = callbackReference.Replace("'" + ClientID + "'", "ID");
                    String callBackScript = "function CallServer(ID,arg) {" + callbackReference + "; }";
                    //String callBackScript = "function CallServer(arg, context) {alert(arg.toString()+' '+context.toString()); }";
                    cm.RegisterClientScriptBlock(this.GetType(), "CallServer", callBackScript, true);
                }

                if (!cm.IsClientScriptBlockRegistered("CallPostBack"))
                {
                    String postBackReference = cm.GetPostBackEventReference(this, "arg");
                    postBackReference = postBackReference.Replace("'" + ClientID + "'", "ID");
                    postBackReference = postBackReference.Replace("'arg'", "arg");
                    string postBackScript = "function CallPostBack(ID,arg) {" + postBackReference + ";}";
                    cm.RegisterClientScriptBlock(this.GetType(), "CallPostBack", postBackScript, true);
                }

                //string StartUP = "window.onload = function() {Initialize(\"" + ClientID + "\")}";
                string StartUP = "Initialize(\"" + ClientID + "\");";
                cm.RegisterStartupScript(this.GetType(), "StartUp" + ClientID, StartUP, true);

                string resourceName = "DotSpatial.WebControls.Script.WebDsScript.js";
                cm.RegisterClientScriptResource(GetType(), resourceName);

                resourceName = "DotSpatial.WebControls.Script.WebToolBar.js";
                cm.RegisterClientScriptResource(GetType(), resourceName);

                resourceName = "DotSpatial.WebControls.Script.wz_jsgraphics.js";
                cm.RegisterClientScriptResource(GetType(), resourceName);

// These .js scripts no longer needed with HTML tooltips (title):
//                resourceName = "DotSpatial.WebControls.Script.wz_tooltip.js";
//                cm.RegisterClientScriptResource(GetType(), resourceName);

//                resourceName = "DotSpatial.WebControls.Script.tip_balloon.js";
//                cm.RegisterClientScriptResource(GetType(), resourceName);

                resourceName = "DotSpatial.WebControls.Script.CookieManager.js";
                cm.RegisterClientScriptResource(GetType(), resourceName);
            }
        }
Example #10
0
 public static void AddAttributesToGridRow(ClientScriptManager manager, GridView grid)
 {
     foreach (GridViewRow r in grid.Rows)
     {
         if (r.RowType == DataControlRowType.DataRow)
         {
             r.Attributes["onmouseover"] = "this.style.cursor='pointer';this.style.textDecoration='underline';";
             r.Attributes["onmouseout"]  = "this.style.textDecoration='none';";
             r.ToolTip = "Click to select row";
             r.Attributes["onclick"] = manager.GetPostBackEventReference(grid, "Select$" + r.RowIndex, true);
         }
     }
 }
Example #11
0
    /// <summary>
    /// Vindicate Fingerprint
    /// </summary>
    /// <returns>user and fingerprint message</returns>
    private void BK_FPIdentify()
    {
        //Get Agent Info
        StringBuilder af_AgentInfo = new StringBuilder(60);

        if (isFirstGetAgentInfo)
        {
            begin = DateTime.Now;
            lock (synObj)
            {
                _ResultCode = GetAgentInfo(af_AgentInfo);
                agentInfo   = af_AgentInfo.ToString();
                end         = DateTime.Now;
                Log("GetAgentInfo");
            }
        }
        else
        {
            af_AgentInfo.Append(agentInfo);
        }
        //Write Verify OCX
        Page.Response.ContentType = "text/html";
        Page.Response.Write("<html>");
        Page.Response.Write("<BODY bgcolor=#FFFFFF >");
        Page.Response.Write("<FORM  id=VerifyForm method=post name=EnrollFormEnroll >");
        Page.Response.Write("	<div style='display:none'><OBJECT ID=VerifyX  ");
        Page.Response.Write("		classid=clsid:"+ this.OcxClassID);
        Page.Response.Write("		codebase="+ this.OcxName);
        Page.Response.Write("		hspace=0  ");
        Page.Response.Write("		vspace=0 >");
        Page.Response.Write("		<PARAM name=IconVisible VALUE=0>");
        Page.Response.Write("	</OBJECT></div>");
        Page.Response.Write("</FORM>");
        Page.Response.Write("</BODY>");
        Page.Response.Write("</html>");

        //Dialog
        //  string sFinger = "";
        //   string sAuthenID = "sa";
        //    string sAuthenPwd = "sa";
        string SCP_SCRIPT_START    = "\n<script language=\"javascript\">\n";
        string SCP_SET_AGENT_INFO  = "VerifyForm.VerifyX.SetAgentInfo(\"" + af_AgentInfo + "\");\n";
        string SCP_AUTHEN          = "strTemplateData = '" + (int)ProcID.FPIdentify + ",' + VerifyForm.VerifyX.AuthenDlgExport(\"" + "" + "\", \"" + "" + "\", 0);\n ";
        ClientScriptManager newCSM = Page.ClientScript;
        string SCP_SET_POST_BACK   = Regex.Replace(newCSM.GetPostBackEventReference(this, ""), "''", "strTemplateData") + "\n";
        string SCP_SCRIPT_END      = "</script>\n";

        newCSM.RegisterStartupScript(this.GetType(), this.GetHashCode().ToString(),
                                     SCP_SCRIPT_START + SCP_SET_AGENT_INFO + SCP_AUTHEN + SCP_SET_POST_BACK + SCP_SCRIPT_END);
        //TempLog.Info("结束Html的输出!");
    }
Example #12
0
        protected override void RenderAttributes(HtmlTextWriter writer)
        {
#if NET_2_0
            if (Page != null && Events [ServerClickEvent] != null)
            {
                PostBackOptions options = GetPostBackOptions();
                Attributes ["onclick"] += Page.ClientScript.GetPostBackEventReference(options, true);
                writer.WriteAttribute("language", "javascript");
            }
#else
            ClientScriptManager csm = new ClientScriptManager(Page);
            bool postback           = false;

            if (Page != null && Events [ServerClickEvent] != null)
            {
                postback = true;
            }

            if (CausesValidation && Page != null && Page.AreValidatorsUplevel())
            {
                if (postback)
                {
                    writer.WriteAttribute("onclick",
                                          String.Concat("javascript:{if (typeof(Page_ClientValidate) != 'function' ||  Page_ClientValidate()) ",
                                                        csm.GetPostBackEventReference(this, String.Empty), "}"));
                }
                else
                {
                    writer.WriteAttribute("onclick",
                                          "if (typeof(Page_ClientValidate) == 'function') Page_ClientValidate();");
                }

                writer.WriteAttribute("language", "javascript");
            }
            else if (postback)
            {
                writer.WriteAttribute("onclick",
                                      Page.ClientScript.GetPostBackClientHyperlink(this, ""));

                writer.WriteAttribute("language", "javascript");
            }
#endif

            base.RenderAttributes(writer);
        }
Example #13
0
        /// <summary>
        /// Registers the clientside postback script with the page.
        /// </summary>
        private void RegisterPostbackScript()
        {
            ClientScriptManager scriptMan = Page.ClientScript;

            if (!scriptMan.IsClientScriptBlockRegistered(PostbackScriptName))
            {
                System.Text.StringBuilder script = new System.Text.StringBuilder();
                script.Append("\n");
                script.Append("function ResizeMonitor_Postback() {\n");
                script.Append("ResizeMonitor_SaveDimensions();\n");
                script.Append(scriptMan.GetPostBackEventReference(this, ""));
                script.Append(";\n}\n");
                script.Append(this.GetClientVariableDeclaration("TimeoutLength", this.Delay.ToString(CultureInfo.InvariantCulture)));
                script.Append(this.GetClientVariableDeclaration("WidthHolder", this.widthHolder.UniqueID, true));
                script.Append(this.GetClientVariableDeclaration("HeightHolder", this.heightHolder.UniqueID, true));
                script.Append("\n");

                scriptMan.RegisterClientScriptBlock(typeof(ResizeMonitor), PostbackScriptName, script.ToString(), true);
            }
        }
Example #14
0
    /// <summary>
    /// Update Enroll user fingerprint
    /// </summary>
    /// <param name="aUserID">The user will be Update fingerprint </param>
    /// <param name="aEnrolledFingers">The user already enrolled fingerprints</param>
    /// <returns>0=success,else=falure.</returns>
    private void BK_FPUpdateEnroll(string aUserID, string aEnrolledFingers)
    {
        //Get Agent Info
        StringBuilder af_AgentInfo = new StringBuilder(60);

        _ResultCode = GetAgentInfo(af_AgentInfo);

        //Write Enroll OCX
        Page.Response.ContentType = "text/html";
        Page.Response.Write("<html>");
        Page.Response.Write("<BODY bgcolor=#FFFFFF >");
        Page.Response.Write("<FORM  id=EnrollForm method=post name=EnrollFormEnroll >");
        Page.Response.Write("	<OBJECT ID=EnrollX  ");
        Page.Response.Write("		classid=clsid:"+ this.OcxClassID);
        Page.Response.Write("		codebase="+ this.OcxName);
        Page.Response.Write("		hspace=0  ");
        Page.Response.Write("		vspace=0 >");
        Page.Response.Write("		<PARAM name=IconVisible VALUE=0>");
        Page.Response.Write("	</OBJECT>");
        Page.Response.Write("</FORM>");
        Page.Response.Write("</BODY>");
        Page.Response.Write("</html>");

        //Dialog
        string sFinger             = aEnrolledFingers;
        string sAuthenID           = this.AuthenID;
        string sAuthenPwd          = this.AuthenPwd;
        string SCP_SCRIPT_START    = "\n<script language=\"javascript\">\n";
        string SCP_SET_AGENT_INFO  = "EnrollForm.EnrollX.SetAgentInfo(\"" + af_AgentInfo + "\");\n";
        string SCP_ENROLL_BY_PWD   = "strTemplateData = '" + (int)ProcID.EnrollByPwdProc + ",' + EnrollForm.EnrollX.EnrollByPwdExport(\"" + aUserID + "\", \"" + sFinger + "\", \" \", 0, 0, \"" + sAuthenID + "\", \"" + sAuthenPwd + "\"); \n";
        ClientScriptManager newCSM = Page.ClientScript;
        string SCP_SET_POST_BACK   = Regex.Replace(newCSM.GetPostBackEventReference(this, ""), "''", "strTemplateData") + "\n";
        string SCP_SCRIPT_END      = "</script>\n";

        newCSM.RegisterStartupScript(this.GetType(), this.GetHashCode().ToString(),
                                     SCP_SCRIPT_START + SCP_SET_AGENT_INFO + SCP_ENROLL_BY_PWD + SCP_SET_POST_BACK + SCP_SCRIPT_END);
    }
Example #15
0
        protected void Page_PreRender(object sender, EventArgs e)
        {
            //bool uploadVideoAccess = SessionManager.CheckUserPrivilege(SysPriv.config, SysScope.media);
            //rbNew.Visible = uploadVideoAccess;


            if (IsPostBack)
            {
                RadPersistenceManager1.StorageProviderKey = SessionManager.UserContext.Person.PERSON_ID.ToString();
                RadPersistenceManager1.SaveState();

                if (SessionManager.ReturnStatus == true)
                {
                    if (SessionManager.ReturnObject is string)
                    {
                        string type = SessionManager.ReturnObject as string;
                        switch (type)
                        {
                        case "DisplayVideos":
                            UpdateDisplayState(DisplayState.VideoList);
                            break;

                        case "AddVideo":                                 // we added the video, now we want to go into edit mode
                        case "Notification":                             // this is when we select the video to edit from the list
                            uclVideoForm.EditVideoId = SessionManager.ReturnRecordID;
                            UpdateDisplayState(DisplayState.VideoEdit);
                            // need to determine if the Audit is past due and force it into display mode (probelm when coming from Calendar)
                            //string auditStatus = EHSAuditMgr.SelectAuditStatus(SessionManager.ReturnRecordID);
                            //if (auditStatus == "C")
                            //	UpdateDisplayState(DisplayState.AuditNotificationDisplay);
                            //else
                            //	UpdateDisplayState(DisplayState.AuditNotificationEdit);
                            //if (isDirected)
                            //{
                            //	rbNew.Visible = false;
                            //	uclAuditForm.EnableReturnButton(false);
                            //}
                            break;

                        case "DisplayOnly":
                            uclVideoForm.EditVideoId = SessionManager.ReturnRecordID;
                            UpdateDisplayState(DisplayState.VideoDisplay);
                            //if (isDirected)
                            //{
                            //	rbNew.Visible = false;
                            //	uclAuditForm.EnableReturnButton(false);
                            //}
                            break;
                        }
                    }
                    SessionManager.ClearReturns();
                }
            }
            else
            {
                //Ucl_DocMgr ucl = (Ucl_DocMgr)this.Master.FindControl("uclDocSelect");
                //if (ucl != null)
                //{
                //	ucl.BindDocumentSelect("EHS", 2, true, true, "");
                //}

                if (SessionManager.ReturnStatus == true && SessionManager.ReturnObject is string)
                {
                    try
                    {
                        // from inbox
                        DisplayNonPostback();
                        SessionManager.ReturnRecordID = Convert.ToDecimal(SessionManager.ReturnObject.ToString());
                        SessionManager.ReturnObject   = "Notification";
                        SessionManager.ReturnStatus   = true;
                        //isDirected = true;

                        StringBuilder       sbScript = new StringBuilder();
                        ClientScriptManager cs       = Page.ClientScript;

                        sbScript.Append("<script language='JavaScript' type='text/javascript'>\n");
                        sbScript.Append("<!--\n");
                        sbScript.Append(cs.GetPostBackEventReference(this, "PBArg") + ";\n");
                        sbScript.Append("// -->\n");
                        sbScript.Append("</script>\n");

                        cs.RegisterStartupScript(this.GetType(), "AutoPostBackScript", sbScript.ToString());
                    }
                    catch
                    {
                        // not a number, parse as type
                        DisplayNonPostback();
                    }
                }
                else
                {
                    DisplayNonPostback();
                }
            }
        }
		protected override void RenderAttributes (HtmlTextWriter writer)
		{
#if NET_2_0
			CultureInfo inv = Helpers.InvariantCulture;
			string input_type = Type;
			if (0 != String.Compare (input_type, "reset", true, inv) &&
				((0 == String.Compare (input_type, "submit", true, inv)) ||
				(0 == String.Compare (input_type, "button", true, inv) && Events [ServerClickEvent] != null))) {

				string onclick = String.Empty;
				if (Attributes ["onclick"] != null) {
					onclick = ClientScriptManager.EnsureEndsWithSemicolon (Attributes ["onclick"] + onclick);
					Attributes.Remove ("onclick");
				}
				if (Page != null) {
					PostBackOptions options = GetPostBackOptions ();
					onclick += Page.ClientScript.GetPostBackEventReference (options, true);
				}

				if (onclick.Length > 0) {
					writer.WriteAttribute ("onclick", onclick, true);
					writer.WriteAttribute ("language", "javascript");
				}
			}
#else
			if (RenderOnClick ()) {
				string oc = null;
				ClientScriptManager csm = new ClientScriptManager (Page);
				if (Page.AreValidatorsUplevel ()) {
					oc = csm.GetClientValidationEvent ();
				} else if (Events [ServerClickEvent] != null) {
					oc = Attributes ["onclick"] + " " + csm.GetPostBackEventReference (this, "");
				}
				
				if (oc != null) {
					writer.WriteAttribute ("language", "javascript");
					writer.WriteAttribute ("onclick", oc, true);
				}
			}
#endif

			Attributes.Remove ("CausesValidation");
#if NET_2_0
			// LAMESPEC: MS doesn't actually remove this
			//attribute.  it shows up in the rendered
			//output.

			// Attributes.Remove("ValidationGroup");
#endif
			base.RenderAttributes (writer);
		}
Example #17
0
        private void renderBackUI(HtmlTextWriter writer)
        {
            string url = string.Empty;
            ClientScriptManager cs = Page.ClientScript;
            int begin, end;

            setbeginend(out begin, out end);

            //writer.Write("<div style=\"width:100%;height:25px; line-height:25px;\"><div style=\"float:left; padding-left:10px;\">");
            //writer.Write(string.Format("<span style=\"font-weight:normal \">" + _beforeRecountCountText + "</span><span style=\"color:" + m_NumberColor + "\">{0}</span><span style=\"font-weight:normal \">" + _afterRecountCountText + ",</span>&nbsp;" +
            //                           "<span style=\"font-weight:normal \">当前第</span><span style=\"color:" + m_NumberColor + "\">{1}</span><span style=\"font-weight:normal \">页,共<span style=\"color:" + m_NumberColor + ";\">{2}</span><span style=\"font-weight:normal \">页</span>&nbsp;&nbsp;", RecordCount, PageIndex, PageCount));
            //writer.Write("</div><div style=\"float:right; padding-right:5px; white-space:nowrap;\">");
            if (IsPostModel)
            {
                writer.Write("<a href=\"javascript:" + cs.GetPostBackEventReference(this, "1") + "\" class=\"\" style=\"color:Black;\">" + _firstPageText + "</a>&nbsp;");

                if (PageIndex > 1)
                {
                    writer.Write("<a href=\"javascript:" + cs.GetPostBackEventReference(this, Convert.ToString(PageIndex - 1)) + "\" style=\"color:Black;\" class=\"\">" + _prePageText + "</a>&nbsp;");
                }
                else
                {
                    writer.Write(_prePageText + "&nbsp;");
                }
                for (int i = begin; i < end + 1; i++)
                {
                    if (i != PageIndex)
                    {
                        writer.Write("<a href=\"javascript:" + cs.GetPostBackEventReference(this, i.ToString()) + "\" class=\"\">" + i + "</a>&nbsp;");
                    }
                    else
                    {
                        writer.Write(string.Format("<span style=\"color:" + m_NumberColor + "\">{0}</span>&nbsp;", i));
                    }
                }
                if (PageIndex < PageCount)
                {
                    writer.Write("&nbsp;<a href=\"javascript:" + cs.GetPostBackEventReference(this, Convert.ToString(PageIndex + 1)) + "\" style=\"color:Black;\" class=\"\">" + _nextPageText + "</a>&nbsp;");
                }
                else
                {
                    writer.Write(_nextPageText + "&nbsp;");
                }
                writer.Write("<a href=\"javascript:" + cs.GetPostBackEventReference(this, PageCount.ToString()) +
                             "\" class=\"\" style=\"color:Black;\">" + _lastPageText + "</a>&nbsp;");
            }
            else
            {
                if (string.IsNullOrEmpty(UrlPathText))
                {
                    url = HttpContext.Current.Request.Url.PathAndQuery;
                    Regex reg = new Regex(@"(\?|&){0,1}" + queryString + "=[^&]*", RegexOptions.IgnoreCase);
                    url = reg.Replace(url, string.Empty);
                    if (url.IndexOf("?") >= 0)
                    {
                        url += "&" + queryString + "={0}";
                    }
                    else
                    {
                        url += "?" + queryString + "={0}";
                    }
                }
                else
                {
                    url = UrlPathText;
                }

                m_nPageIndex = PageIndex;

                writer.Write(string.Format("<a href=" + url + " class=\"\">" + _firstPageText + "</a>&nbsp;", 1));
                if (PageIndex > 1)
                {
                    writer.Write(string.Format("<a href=" + url + " class=\"\">" + _prePageText + "</a>&nbsp;", PageIndex - 1));
                }
                else
                {
                    writer.Write(_prePageText + "&nbsp;");
                }
                for (int i = begin; i < end + 1; i++)
                {
                    if (i != m_nPageIndex)
                    {
                        writer.Write(string.Format("<a href=" + url + " class=\"\">{0}</a>&nbsp;", i));
                    }
                    else
                    {
                        writer.Write(string.Format("<span style=\"color:" + m_NumberColor + "\">{0}</span>&nbsp;", i));
                    }
                }
                if (m_nPageIndex < PageCount)
                {
                    writer.Write(string.Format("<a href=" + url + " class=\"\">" + _nextPageText + "</a>&nbsp;", PageIndex + 1));
                }
                else
                {
                    writer.Write(_nextPageText + "&nbsp");
                }
                writer.Write(string.Format("&nbsp;<a href=" + url + " class=\"\">" + _lastPageText + "</a>", PageCount));
            }
            writer.Write("</div></div>");
        }
Example #18
0
        private void renderForeUI(HtmlTextWriter writer)
        {
            string url             = string.Empty;
            ClientScriptManager cs = Page.ClientScript;

            StringBuilder sb = new StringBuilder();

            int begin, end;

            setbeginend(out begin, out end);

            sb.Append(" <div class=\"");
            sb.Append(CssClass == "" ? "sabrosus" : CssClass);
            sb.Append("\"><div>");

            if (_showRecordCount)
            {
                sb.Append(_beforeRecountCountText);
                sb.Append("<span style=\"color:");
                sb.Append(m_NumberColor);
                sb.Append(";\">");
                sb.Append(m_nRecordCount);
                sb.Append("</span>");
                sb.Append(_afterRecountCountText);
                sb.Append("&nbsp;&nbsp;");
            }
            if (m_bIsPostModel)
            {
                if (m_nPageIndex == 1)
                {
                    sb.Append("<span class=\"disabled\">");
                    sb.Append(_firstPageText);
                    sb.Append("</span>");

                    sb.Append("<span class=\"disabled\">");
                    sb.Append(_prePageText);
                    sb.Append("</span>");
                }
                else
                {
                    sb.Append("<span class=\"pagination\">");
                    sb.Append("<a href=\"javascript:");
                    sb.Append(cs.GetPostBackEventReference(this, "1"));
                    sb.Append("\">");
                    sb.Append(_firstPageText);
                    sb.Append("</a></span>");

                    sb.Append("<span class=\"pagination\">");
                    sb.Append("<a href=\"javascript:");
                    sb.Append(cs.GetPostBackEventReference(this, (m_nPageIndex - 1).ToString()));
                    sb.Append("\">");
                    sb.Append(_prePageText);
                    sb.Append("</a></span>");
                }
                for (int i = begin; i <= end; i++)
                {
                    if (i != m_nPageIndex)
                    {
                        sb.Append("<span class=\"pagination\"><a href=\"javascript:");
                        sb.Append(cs.GetPostBackEventReference(this, i.ToString()));
                        sb.Append("\">");
                        sb.Append(i);
                        sb.Append("</a></span>");
                    }
                    else
                    {
                        sb.Append(" <span class=\"current\">");
                        sb.Append(i);
                        sb.Append("</span>");
                    }
                }
                if (m_nPageIndex < PageCount)
                {
                    sb.Append("<span class=\"pagination\">");
                    sb.Append("<a href=\"javascript:");
                    sb.Append(cs.GetPostBackEventReference(this, (m_nPageIndex + 1).ToString()));
                    sb.Append("\">");
                    sb.Append(_nextPageText);
                    sb.Append("</a></span>");

                    sb.Append("<span class=\"pagination\">");
                    sb.Append("<a href=\"javascript:");
                    sb.Append(cs.GetPostBackEventReference(this, PageCount.ToString()));
                    sb.Append("\">");
                    sb.Append(_lastPageText);
                    sb.Append("</a></span>");
                }
                else
                {
                    sb.Append("<span class=\"disabled\">");
                    sb.Append(_nextPageText);
                    sb.Append("</span>");

                    sb.Append("<span class=\"disabled\">");
                    sb.Append(_lastPageText);
                    sb.Append("</span>");
                }
            }
            else
            {
                if (string.IsNullOrEmpty(UrlPathText))
                {
                    url = HttpContext.Current.Request.Url.PathAndQuery;
                    Regex reg = new Regex(@"(\?|&){0,1}" + queryString + "=[^&]*", RegexOptions.IgnoreCase);
                    url = reg.Replace(url, string.Empty);
                    if (url.IndexOf("?") >= 0)
                    {
                        url += "&" + queryString + "={0}";
                    }
                    else
                    {
                        url += "?" + queryString + "={0}";
                    }
                }
                else
                {
                    url = UrlPathText;
                }

                m_nPageIndex = PageIndex;//sjfe_add 10-29

                if (m_nPageIndex == 1)
                {
                    sb.Append("<span class=\"disabled\">");
                    sb.Append(_firstPageText);
                    sb.Append("</span>");

                    sb.Append("<span class=\"disabled\">");
                    sb.Append(_prePageText);
                    sb.Append("</span>");
                }
                else
                {
                    sb.Append("<span class=\"pagination\">");
                    sb.Append("<a href=\"");
                    sb.Append(String.Format(url, 1));
                    sb.Append("\">");
                    sb.Append(_firstPageText);
                    sb.Append("</a></span>");

                    sb.Append("<span class=\"pagination\">");
                    sb.Append("<a href=\"");
                    sb.Append(String.Format(url, (m_nPageIndex - 1)));
                    sb.Append("\">");
                    sb.Append(_prePageText);
                    sb.Append("</a></span>");
                }
                for (int i = begin; i <= end; i++)
                {
                    if (i != m_nPageIndex)
                    {
                        sb.Append("<span class=\"pagination\"><a href=\"");
                        sb.Append(String.Format(url, i));
                        sb.Append("\">");
                        sb.Append(i);
                        sb.Append("</a></span>");
                    }
                    else
                    {
                        sb.Append(" <span class=\"current\">");
                        sb.Append(i);
                        sb.Append("</span>");
                    }
                }
                if (m_nPageIndex < PageCount)
                {
                    sb.Append("<span class=\"pagination\">");
                    sb.Append("<a href=\"");
                    sb.Append(String.Format(url, (m_nPageIndex + 1)));
                    sb.Append("\">");
                    sb.Append(_nextPageText);
                    sb.Append("</a></span>");

                    sb.Append("<span class=\"pagination\">");
                    sb.Append("<a href=\"");
                    sb.Append(String.Format(url, PageCount));
                    sb.Append("\">");
                    sb.Append(_lastPageText);
                    sb.Append("</a></span>");
                }
                else
                {
                    sb.Append("<span class=\"disabled\">");
                    sb.Append(_nextPageText);
                    sb.Append("</span>");

                    sb.Append("<span class=\"disabled\">");
                    sb.Append(_lastPageText);
                    sb.Append("</span>");
                }
            }

            if (_showPageState)
            {
                sb.Append("&nbsp;&nbsp;");
                sb.Append("第<span style=\"font-weight: bold;color:");
                sb.Append(m_NumberColor);
                sb.Append(";\">");
                sb.Append(m_nPageIndex);
                sb.Append("</span>页/共<span style=\"font-weight: bold;color:");
                sb.Append(m_NumberColor);
                sb.Append(";\">");
                sb.Append(PageCount);
                sb.Append("</span>页");
            }

            sb.Append("  </div></div>");

            writer.Write(sb.ToString());
        }
Example #19
0
        private void renderForeTableUI(HtmlTextWriter writer)
        {
            string url             = string.Empty;
            ClientScriptManager cs = Page.ClientScript;

            StringBuilder sb = new StringBuilder();

            int begin, end;

            setbeginend(out begin, out end);

            sb.Append(" <div class=\"");
            sb.Append(CssClass == "" ? "tdsabrosus" : CssClass); //<!--只做了tdsabrosus和tdyahoo、tddigg-->
            sb.Append(
                "\"><table cellpadding=\"0\" cellspacing=\"3\" border=\"0\" width=\"100%\"><tr><td width=\"100%\" align=\"center\">");
            sb.Append("<table cellpadding=\"0\" cellspacing=\"3\" border=\"0\"> <tr>");

            if (_showRecordCount)
            {
                sb.Append("<td>");
                sb.Append(_beforeRecountCountText);
                sb.Append("<span style=\"color:");
                sb.Append(m_NumberColor);
                sb.Append(";\">");
                sb.Append(m_nRecordCount);
                sb.Append("</span>");
                sb.Append(_afterRecountCountText);
                sb.Append("&nbsp;&nbsp;");
                sb.Append("</td>");
            }
            if (m_bIsPostModel)
            {
                if (m_nPageIndex == 1)
                {
                    sb.Append("<td class=\"firstlastdisbale\">");
                    sb.Append(_firstPageText);
                    sb.Append("</td>");

                    sb.Append("<td class=\"firstlastdisbale\">");
                    sb.Append(_prePageText);
                    sb.Append("</td>");
                }
                else
                {
                    sb.Append(
                        "<td class=\"firstlast\" onmouseover=\"javascript:this.className='firstlasthover';\" onmouseout=\"javascript:this.className='firstlast';\" ");
                    sb.Append("onclick=\"javascript:");
                    sb.Append(cs.GetPostBackEventReference(this, "1"));
                    sb.Append("\">");
                    sb.Append(_firstPageText);
                    sb.Append("</td>");

                    sb.Append(
                        "<td class=\"firstlast\" onmouseover=\"javascript:this.className='firstlasthover';\" onmouseout=\"javascript:this.className='firstlast';\" ");
                    sb.Append("onclick=\"javascript:");
                    sb.Append(cs.GetPostBackEventReference(this, (m_nPageIndex - 1).ToString()));
                    sb.Append("\">");
                    sb.Append(_prePageText);
                    sb.Append("</td>");
                }
                for (int i = begin; i <= end; i++)
                {
                    if (i != m_nPageIndex)
                    {
                        sb.Append(
                            "<td class=\"tdcomm\" onmouseover=\"javascript:this.className='tdhover';\" onmouseout=\"javascript:this.className='tdcomm';\" ");
                        sb.Append("onclick=\"javascript:");
                        sb.Append(cs.GetPostBackEventReference(this, i.ToString()));
                        sb.Append("\">");
                        sb.Append(i);
                        sb.Append("</td>");
                    }
                    else
                    {
                        sb.Append("<td class=\"current\">");
                        sb.Append(i);
                        sb.Append("</td>");
                    }
                }
                if (m_nPageIndex < PageCount)
                {
                    sb.Append(
                        "<td class=\"firstlast\" onmouseover=\"javascript:this.className='firstlasthover';\" onmouseout=\"javascript:this.className='firstlast';\" ");
                    sb.Append("onclick=\"javascript:");
                    sb.Append(cs.GetPostBackEventReference(this, (m_nPageIndex + 1).ToString()));
                    sb.Append("\">");
                    sb.Append(_nextPageText);
                    sb.Append("</td>");

                    sb.Append(
                        "<td class=\"firstlast\" onmouseover=\"javascript:this.className='firstlasthover';\" onmouseout=\"javascript:this.className='firstlast';\" ");
                    sb.Append("onclick=\"javascript:");
                    sb.Append(cs.GetPostBackEventReference(this, PageCount.ToString()));
                    sb.Append("\">");
                    sb.Append(_lastPageText);
                    sb.Append("</td>");
                }
                else
                {
                    sb.Append("<td class=\"firstlastdisbale\">");
                    sb.Append(_nextPageText);
                    sb.Append("</td>");

                    sb.Append("<td class=\"firstlastdisbale\">");
                    sb.Append(_lastPageText);
                    sb.Append("</td>");
                }
            }
            else
            {
                if (string.IsNullOrEmpty(UrlPathText))
                {
                    url = HttpContext.Current.Request.Url.PathAndQuery;
                    Regex reg = new Regex(@"(\?|&){0,1}" + queryString + "=[^&]*", RegexOptions.IgnoreCase);
                    url = reg.Replace(url, string.Empty);
                    if (url.IndexOf("?") >= 0)
                    {
                        url += "&" + queryString + "={0}";
                    }
                    else
                    {
                        url += "?" + queryString + "={0}";
                    }
                }
                else
                {
                    url = UrlPathText;
                }

                m_nPageIndex = PageIndex; //sjfe_add 10-29

                if (m_nPageIndex == 1)
                {
                    sb.Append("<td class=\"firstlastdisbale\">");
                    sb.Append(_firstPageText);
                    sb.Append("</td>");

                    sb.Append("<td class=\"firstlastdisbale\">");
                    sb.Append(_prePageText);
                    sb.Append("</td>");
                }
                else
                {
                    sb.Append(
                        "<td class=\"firstlast\" onmouseover=\"javascript:this.className='firstlasthover';\" onmouseout=\"javascript:this.className='firstlast';\" ");
                    sb.Append("onclick=\"javascript:window.location.href='");
                    sb.Append(String.Format(url, 1));
                    sb.Append("'\">");
                    sb.Append(_firstPageText);
                    sb.Append("</td>");

                    sb.Append(
                        "<td class=\"firstlast\" onmouseover=\"javascript:this.className='firstlasthover';\" onmouseout=\"javascript:this.className='firstlast';\" ");
                    sb.Append("onclick=\"javascript:window.location.href='");
                    sb.Append(String.Format(url, (m_nPageIndex - 1)));
                    sb.Append("'\">");
                    sb.Append(_prePageText);
                    sb.Append("</td>");
                }
                for (int i = begin; i <= end; i++)
                {
                    if (i != m_nPageIndex)
                    {
                        sb.Append(
                            "<td class=\"tdcomm\" onmouseover=\"javascript:this.className='tdhover';\" onmouseout=\"javascript:this.className='tdcomm';\" ");
                        sb.Append("onclick=\"javascript:window.location.href='");
                        sb.Append(String.Format(url, i));
                        sb.Append("'\">");
                        sb.Append(i);
                        sb.Append("</td>");
                    }
                    else
                    {
                        sb.Append("<td class=\"current\">");
                        sb.Append(i);
                        sb.Append("</td>");
                    }
                }
                if (m_nPageIndex < PageCount)
                {
                    sb.Append(
                        "<td class=\"firstlast\" onmouseover=\"javascript:this.className='firstlasthover';\" onmouseout=\"javascript:this.className='firstlast';\" ");
                    sb.Append("onclick=\"javascript:window.location.href='");
                    sb.Append(String.Format(url, (m_nPageIndex + 1)));
                    sb.Append("'\">");
                    sb.Append(_nextPageText);
                    sb.Append("</td>");

                    sb.Append(
                        "<td class=\"firstlast\" onmouseover=\"javascript:this.className='firstlasthover';\" onmouseout=\"javascript:this.className='firstlast';\" ");
                    sb.Append("onclick=\"javascript:window.location.href='");
                    sb.Append(String.Format(url, PageCount));
                    sb.Append("'\">");
                    sb.Append(_lastPageText);
                    sb.Append("</td>");
                }
                else
                {
                    sb.Append("<td class=\"firstlastdisbale\">");
                    sb.Append(_nextPageText);
                    sb.Append("</td>");

                    sb.Append("<td class=\"firstlastdisbale\">");
                    sb.Append(_lastPageText);
                    sb.Append("</td>");
                }
            }

            if (_showPageState)
            {
                sb.Append("<td>");
                sb.Append("&nbsp;&nbsp;");
                sb.Append("<span style=\"color:");
                sb.Append(m_NumberColor);
                sb.Append(";\">");
                sb.Append(m_nPageIndex);
                sb.Append("/");
                sb.Append(PageCount);
                sb.Append("</span>");
                sb.Append("</td>");
            }

            sb.Append("</tr></table></td></tr></table> </div>  ");

            writer.Write(sb.ToString());
        }
Example #20
0
 public static void AddDoubleClick(ListBox listBox, ClientScriptManager manager)
 {
     listBox.Attributes.Add("ondblclick", manager.GetPostBackEventReference(listBox, "doubleClick"));
 }
 /// <summary>
 /// Returns a string that can be used in a client event to cause postback to the server. The reference string is defined by the specified control that handles the postback and a string argument of additional event information.
 /// </summary>
 /// <returns>
 /// A string that, when treated as script on the client, initiates the postback.
 /// </returns>
 /// <param name="control">The server <see cref="T:System.Web.UI.Control"/> that processes the postback on the server.
 /// </param><param name="argument">A string of optional arguments to pass to the control that processes the postback.
 /// </param><exception cref="T:System.ArgumentNullException">The specified <see cref="T:System.Web.UI.Control"/> is null.
 /// </exception>
 public string GetPostBackEventReference(IControl control, string argument)
 {
     ArgumentUtility.CheckNotNullAndType <Control> ("control", control);
     return(_clientScriptManager.GetPostBackEventReference((Control)control, argument));
 }
Example #22
0
        protected void Page_PreRender(object sender, EventArgs e)
        {
            bool createAuditAccess = SessionManager.CheckUserPrivilege(SysPriv.config, SysScope.audit);

            rbNew.Visible = createAuditAccess;


            if (IsPostBack)
            {
                //if (!uclAuditForm.IsEditContext)
                RadPersistenceManager1.StorageProviderKey = SessionManager.UserContext.Person.PERSON_ID.ToString();
                RadPersistenceManager1.SaveState();

                if (SessionManager.ReturnStatus == true)
                {
                    if (SessionManager.ReturnObject is string)
                    {
                        string type = SessionManager.ReturnObject as string;
                        switch (type)
                        {
                        case "DisplayAudits":
                            UpdateDisplayState(DisplayState.AuditList);
                            break;

                        case "Notification":
                            //UpdateDisplayState(DisplayState.AuditNotificationEdit);
                            //UpdateDisplayState(DisplayState.AuditReportEdit);
                            uclAuditForm.EditAuditId = SessionManager.ReturnRecordID;
                            // need to determine if the Audit is past due and force it into display mode (probelm when coming from Calendar)
                            string auditStatus = EHSAuditMgr.SelectAuditStatus(SessionManager.ReturnRecordID);
                            if (auditStatus == "C")
                            {
                                UpdateDisplayState(DisplayState.AuditNotificationDisplay);
                            }
                            else
                            {
                                UpdateDisplayState(DisplayState.AuditNotificationEdit);
                            }
                            if (isDirected)
                            {
                                rbNew.Visible = false;
                                uclAuditForm.EnableReturnButton(false);
                            }
                            break;

                        case "Closed":
                            uclAuditForm.EditAuditId = SessionManager.ReturnRecordID;
                            UpdateDisplayState(DisplayState.AuditNotificationClosed);
                            if (isDirected)
                            {
                                rbNew.Visible = false;
                                uclAuditForm.EnableReturnButton(false);
                            }
                            break;

                        case "DisplayOnly":
                            uclAuditForm.EditAuditId = SessionManager.ReturnRecordID;
                            UpdateDisplayState(DisplayState.AuditNotificationDisplay);
                            if (isDirected)
                            {
                                rbNew.Visible = false;
                                uclAuditForm.EnableReturnButton(false);
                            }
                            break;
                        }
                    }
                    SessionManager.ClearReturns();
                }
            }
            else
            {
                Ucl_DocMgr ucl = (Ucl_DocMgr)this.Master.FindControl("uclDocSelect");
                if (ucl != null)
                {
                    ucl.BindDocumentSelect("EHS", 2, true, true, "");
                }

                if (SessionManager.ReturnStatus == true && SessionManager.ReturnObject is string)
                {
                    try
                    {
                        // from inbox
                        DisplayNonPostback();
                        SessionManager.ReturnRecordID = Convert.ToDecimal(SessionManager.ReturnObject.ToString());
                        SessionManager.ReturnObject   = "Notification";
                        SessionManager.ReturnStatus   = true;
                        isDirected = true;

                        StringBuilder       sbScript = new StringBuilder();
                        ClientScriptManager cs       = Page.ClientScript;

                        sbScript.Append("<script language='JavaScript' type='text/javascript'>\n");
                        sbScript.Append("<!--\n");
                        sbScript.Append(cs.GetPostBackEventReference(this, "PBArg") + ";\n");
                        sbScript.Append("// -->\n");
                        sbScript.Append("</script>\n");

                        cs.RegisterStartupScript(this.GetType(), "AutoPostBackScript", sbScript.ToString());
                    }
                    catch
                    {
                        // not a number, parse as type
                        DisplayNonPostback();
                    }
                }
                else
                {
                    DisplayNonPostback();
                }
            }
            // for now, we will only let 'admin' create audits
            //if (!SessionManager.UserContext.Person.SSO_ID.ToLower().Equals("admin"))
            //	rbNew.Visible = false;
        }
Example #23
0
		protected override void AddAttributesToRender (HtmlTextWriter w)
		{
			Page page = Page;
			if (page != null)
				page.VerifyRenderingInServerForm (this);

			bool enabled = IsEnabled;
#if NET_2_0
			string onclick = OnClientClick;
			onclick = ClientScriptManager.EnsureEndsWithSemicolon (onclick);
			if (HasAttributes && Attributes ["onclick"] != null) {
				onclick = ClientScriptManager.EnsureEndsWithSemicolon (onclick + Attributes ["onclick"]);
				Attributes.Remove ("onclick");
			}

			if (onclick.Length > 0)
				w.AddAttribute (HtmlTextWriterAttribute.Onclick, onclick);

			if (enabled && page != null) {
				PostBackOptions options = GetPostBackOptions ();
				string href = page.ClientScript.GetPostBackEventReference (options, true);
				w.AddAttribute (HtmlTextWriterAttribute.Href, href);
			}
			base.AddAttributesToRender (w);
			AddDisplayStyleAttribute (w);
#else
			base.AddAttributesToRender (w);
			if (page == null || !enabled)
				return;
			
			if (CausesValidation && page.AreValidatorsUplevel ()) {
				ClientScriptManager csm = new ClientScriptManager (page);
				w.AddAttribute (HtmlTextWriterAttribute.Href,
						String.Concat ("javascript:{if (typeof(Page_ClientValidate) == 'function') Page_ClientValidate(); ",
							       csm.GetPostBackEventReference (this, String.Empty), ";}"));
			} else {
				w.AddAttribute (HtmlTextWriterAttribute.Href, page.ClientScript.GetPostBackClientHyperlink (this, String.Empty));
			}
#endif
		}
        protected override void Render(HtmlTextWriter writer)
        {
            string url = string.Empty;
            ClientScriptManager cs = Page.ClientScript;
            int begin, end;

            if (PageIndex < 6)
            {
                begin = 1;
            }
            else
            {
                if (PageIndex + 5 >= PageCount)
                {
                    if (PageCount < 10)
                    {
                        begin = 1;
                    }
                    else
                    {
                        begin = PageCount - 9;
                    }
                }
                else
                {
                    begin = PageIndex - 4;
                }
            }
            if (PageCount < 10)
            {
                end = PageCount;
            }
            else
            {
                end = begin + rightCount;
            }
            string beginRecord = (PageSize * PageIndex - PageSize + 1).ToString();
            string endRecord   = (PageSize * PageIndex).ToString();

            if (PageIndex == PageCount)
            {
                endRecord = RecordCount.ToString();
            }
            if (IsSpecial)
            {
                writer.Write("<div class=\"page\"><div class=\"row\"><ul class=\"page\">");
                if (IsPostModel)
                {
                    if (PageIndex > 1)
                    {
                        writer.Write("<li><a href=\"javascript:" + cs.GetPostBackEventReference(this, Convert.ToString(PageIndex - 1)) + "\"><</a></li>");
                    }
                    else
                    {
                        writer.Write("<li><a><</a></li>");
                    }
                    for (int i = begin; i < end + 1; i++)
                    {
                        if (i != PageIndex)
                        {
                            writer.Write("<li><a href=\"javascript:" + cs.GetPostBackEventReference(this, i.ToString()) + "\" >" + i + "</a></li>");
                        }
                        else
                        {
                            writer.Write("<li class=\"select\"><a href=\"javascript:" + cs.GetPostBackEventReference(this, i.ToString()) + "\" >" + i + "</a></li>");
                        }
                    }
                    if (PageIndex < PageCount)
                    {
                        writer.Write("<li><a href=\"javascript:" + cs.GetPostBackEventReference(this, Convert.ToString(PageIndex + 1)) + "\">></a></li>");
                    }
                    else
                    {
                        writer.Write("<li><a>></a></li>");
                    }
                }

                writer.Write("</ul></div></div>");
            }
            else
            {
                if (IsEnglish)
                {
                    writer.Write("<div style=\"width:100%;height:25px; line-height:25px;\"><div style=\"float:left; padding-left:10px;\">");
                    writer.Write(string.Format("<span style=\"font-weight:normal \">Total</span><span style=\"color:" + m_NumberColor.Name + "\">{0}</span><span style=\"font-weight:normal \">Records,</span>&nbsp;" +
                                               "<span style=\"font-weight:normal \">Current Page</span><span style=\"color:" + m_NumberColor.Name + "\">{1}</span><span style=\"font-weight:normal \">,Total Page<span style=\"color:" + m_NumberColor.Name + ";\">{2}</span><span style=\"font-weight:normal \"></span>&nbsp;&nbsp;", RecordCount, PageIndex, PageCount));
                    writer.Write("</div><div style=\"float:right; padding-right:5px; white-space:nowrap;\">");
                }
                else
                {
                    writer.Write("<div style=\"width:100%;height:25px; line-height:25px;\"><div style=\"float:left; padding-left:10px;\">");
                    writer.Write(string.Format("<span style=\"font-weight:normal \">共有</span><span style=\"color:" + m_NumberColor.Name + "\">{0}</span><span style=\"font-weight:normal \">条记录,</span>&nbsp;" +
                                               "<span style=\"font-weight:normal \">当前第</span><span style=\"color:" + m_NumberColor.Name + "\">{1}</span><span style=\"font-weight:normal \">页,共<span style=\"color:" + m_NumberColor.Name + ";\">{2}</span><span style=\"font-weight:normal \">页</span>&nbsp;&nbsp;", RecordCount, PageIndex, PageCount));
                    writer.Write("</div><div style=\"float:right; padding-right:5px; white-space:nowrap;\">");
                }
                if (IsEnglish)
                {
                    if (IsPostModel)
                    {
                        writer.Write("<a href=\"javascript:" + cs.GetPostBackEventReference(this, "1") + "\" class=\"pager\">Home</a>&nbsp;");

                        if (PageIndex > 1)
                        {
                            writer.Write("<a href=\"javascript:" + cs.GetPostBackEventReference(this, Convert.ToString(PageIndex - 1)) + "\" class=\"pager\">Last Page</a>&nbsp;");
                        }
                        else
                        {
                            writer.Write("Last Page&nbsp;");
                        }
                        for (int i = begin; i < end + 1; i++)
                        {
                            if (i != PageIndex)
                            {
                                writer.Write("<a href=\"javascript:" + cs.GetPostBackEventReference(this, i.ToString()) + "\" class=\"pager\">" + i + "</a>&nbsp;");
                            }
                            else
                            {
                                writer.Write(string.Format("<span style=\"color:" + m_NumberColor.Name + "\">{0}</span>&nbsp;", i));
                            }
                        }
                        if (PageIndex < PageCount)
                        {
                            writer.Write("&nbsp;<a href=\"javascript:" + cs.GetPostBackEventReference(this, Convert.ToString(PageIndex + 1)) + "\" class=\"pager\">Next Page</a>&nbsp;");
                        }
                        else
                        {
                            writer.Write("Next Page&nbsp;");
                        }
                        writer.Write("<a href=\"javascript:" + cs.GetPostBackEventReference(this, PageCount.ToString()) + "\" class=\"pager\">End</a>&nbsp;");
                    }
                    else
                    {
                        if (string.IsNullOrEmpty(TemplateUrl))
                        {
                            url = HttpContext.Current.Request.Url.PathAndQuery;
                            Regex reg = new Regex(@"(\?|&){0,1}Page=[^&]*", RegexOptions.IgnoreCase);
                            url = reg.Replace(url, string.Empty);
                            if (url.IndexOf("?") >= 0)
                            {
                                url += "&Page={0}";
                            }
                            else
                            {
                                url += "?Page={0}";
                            }
                        }
                        else
                        {
                            url = TemplateUrl;
                        }
                        writer.Write(string.Format("<a href=" + url + " class=\"pager\">Home</a>&nbsp;", 1));
                        if (PageIndex > 1)
                        {
                            writer.Write(string.Format("<a href=" + url + " class=\"pager\">Last Pgae</a>&nbsp;", PageIndex - 1));
                        }
                        else
                        {
                            writer.Write("Last Pgae&nbsp;");
                        }
                        for (int i = begin; i < end + 1; i++)
                        {
                            if (i != PageIndex)
                            {
                                writer.Write(string.Format("<a href=" + url + " class=\"pager\">{0}</a>&nbsp;", i));
                            }
                            else
                            {
                                writer.Write(string.Format("<span style=\"color:" + m_NumberColor.Name + "\">{0}</span>&nbsp;", i));
                            }
                        }
                        if (PageIndex < PageCount)
                        {
                            writer.Write(string.Format("<a href=" + url + " class=\"pager\">Next Page</a>&nbsp;", PageIndex + 1));
                        }
                        else
                        {
                            writer.Write("Next Page&nbsp");
                        }
                        writer.Write(string.Format("&nbsp;<a href=" + url + " class=\"pager\">End</a>", PageCount));
                    }
                }
                else
                {
                    if (IsPostModel)
                    {
                        writer.Write("<a href=\"javascript:" + cs.GetPostBackEventReference(this, "1") + "\" class=\"pager\">首页</a>&nbsp;");

                        if (PageIndex > 1)
                        {
                            writer.Write("<a href=\"javascript:" + cs.GetPostBackEventReference(this, Convert.ToString(PageIndex - 1)) + "\" class=\"pager\">上一页</a>&nbsp;");
                        }
                        else
                        {
                            writer.Write("上一页&nbsp;");
                        }
                        for (int i = begin; i < end + 1; i++)
                        {
                            if (i != PageIndex)
                            {
                                writer.Write("<a href=\"javascript:" + cs.GetPostBackEventReference(this, i.ToString()) + "\" class=\"pager\">" + i + "</a>&nbsp;");
                            }
                            else
                            {
                                writer.Write(string.Format("<span style=\"color:" + m_NumberColor.Name + "\">{0}</span>&nbsp;", i));
                            }
                        }
                        if (PageIndex < PageCount)
                        {
                            writer.Write("&nbsp;<a href=\"javascript:" + cs.GetPostBackEventReference(this, Convert.ToString(PageIndex + 1)) + "\" class=\"pager\">下一页</a>&nbsp;");
                        }
                        else
                        {
                            writer.Write("下一页&nbsp;");
                        }
                        writer.Write("<a href=\"javascript:" + cs.GetPostBackEventReference(this, PageCount.ToString()) + "\" class=\"pager\">尾页</a>&nbsp;");
                    }
                    else
                    {
                        if (string.IsNullOrEmpty(TemplateUrl))
                        {
                            url = HttpContext.Current.Request.Url.PathAndQuery;
                            Regex reg = new Regex(@"(\?|&){0,1}Page=[^&]*", RegexOptions.IgnoreCase);
                            url = reg.Replace(url, string.Empty);
                            if (url.IndexOf("?") >= 0)
                            {
                                url += "&Page={0}";
                            }
                            else
                            {
                                url += "?Page={0}";
                            }
                        }
                        else
                        {
                            url = TemplateUrl;
                        }
                        writer.Write(string.Format("<a href=" + url + " class=\"pager\">首页</a>&nbsp;", 1));
                        if (PageIndex > 1)
                        {
                            writer.Write(string.Format("<a href=" + url + " class=\"pager\">上一页</a>&nbsp;", PageIndex - 1));
                        }
                        else
                        {
                            writer.Write("上一页&nbsp;");
                        }
                        for (int i = begin; i < end + 1; i++)
                        {
                            if (i != PageIndex)
                            {
                                writer.Write(string.Format("<a href=" + url + " class=\"pager\">{0}</a>&nbsp;", i));
                            }
                            else
                            {
                                writer.Write(string.Format("<span style=\"color:" + m_NumberColor.Name + "\">{0}</span>&nbsp;", i));
                            }
                        }
                        if (PageIndex < PageCount)
                        {
                            writer.Write(string.Format("<a href=" + url + " class=\"pager\">下一页</a>&nbsp;", PageIndex + 1));
                        }
                        else
                        {
                            writer.Write("下一页&nbsp");
                        }
                        writer.Write(string.Format("&nbsp;<a href=" + url + " class=\"pager\">尾页</a>", PageCount));
                    }
                }


                writer.Write("</div></div>");
            }
        }
Example #25
0
        /// <summary>
        ///
        /// </summary>
        protected override void CreateChildControls()
        {
            Controls.Clear();


            ClientScriptManager csm = Page.ClientScript;

            //--------------------current language----------------------------------

            //--dl
            if (IsLarge)
            {
                Controls.Add(new LiteralControl("<dl class='language lang_primar lang_description'>"));
            }
            else
            {
                Controls.Add(new LiteralControl("<dl class='language lang_primar lang_name_class'>"));
            }

            //--dt
            string jsStr = CANCEL_BUBBLE + @csm.GetPostBackEventReference(this, "ToggleLanguages");

            Controls.Add(new LiteralControl("<dt onclick=\"" + jsStr + ";\">"));

            //current flag
            string currentFlagSrc = this.Page.ClientScript.GetWebResourceUrl(this.GetType(), String.Format(FLAG_RESOURCE_ROOT, "noimage"));

            if (CurrentLanguage != null)
            {
                currentFlagSrc = this.Page.ClientScript.GetWebResourceUrl(this.GetType(), String.Format(FLAG_RESOURCE_ROOT, CurrentLanguage.Code.ToLower()));
            }

            Controls.Add(new LiteralControl("<img src=" + currentFlagSrc + ">"));
            Controls.Add(new LiteralControl("</img>"));

            //arrow
            string arrowSrc = this.Page.ClientScript.GetWebResourceUrl(this.GetType(), "DictTextBox.Images.arrow_down.png");

            if (LanguagesShown)
            {
                this.Page.ClientScript.GetWebResourceUrl(this.GetType(), "DictTextBox.Images.arrow_up.png");
            }

            Controls.Add(new LiteralControl("<img src=" + arrowSrc + ">"));
            Controls.Add(new LiteralControl("</img>"));

            //--dd
            Controls.Add(new LiteralControl("<dd>"));

            //textbox

            textBox      = new TextBox();
            textBox.ID   = "TextBox";
            textBox.Text = this.Text;
            if (CurrentLanguage != null)
            {
                textBox.Attributes["CurrentLanguageID"] = CurrentLanguage.ID.ToString();
            }
            textBox.Attributes["onfocus"] = "focusOnDictTextBox(this);";

            //js events
            string keyEvent = "";

            if (!this.IgnoreEnterForPostback)
            {
                keyEvent += @"if (event.keyCode==13 && !event.shiftKey) {"
                            + csm.GetPostBackEventReference(this, "ConfirmChanges") +
                            @"}";
            }
            if (!this.IgnoreTabForPostback)
            {
                keyEvent += @"if (event.keyCode == 9 && !event.shiftKey){"
                            + csm.GetPostBackEventReference(this, "ProcessTab") +
                            @"}";
            }
            if (!this.IgnoreCancelForPostback)
            {
                keyEvent += @"if (event.keyCode == 27){"
                            + csm.GetPostBackEventReference(this, "CancelChanges") +
                            @"}";
            }

            if (keyEvent != "")
            {
                textBox.Attributes["onkeydown"] = CANCEL_BUBBLE + keyEvent;
            }

            //textBox.Attributes["onkeydown"] = CANCEL_BUBBLE + @"if (event.keyCode==13 && !event.shiftKey) {" + csm.GetPostBackEventReference(this, "ConfirmChanges") + @"} if (event.keyCode == 9 && !event.shiftKey){" + csm.GetPostBackEventReference(this, "ProcessTab") + @"} if (event.keyCode == 27){" + csm.GetPostBackEventReference(this, "CancelChanges") + "}";

            if (IsLarge)
            {
                textBox.TextMode = TextBoxMode.MultiLine;
            }
            else
            {
                textBox.CssClass = "inline-edit-input";
                textBox.TextMode = TextBoxMode.SingleLine;
            }
            textBox.CssClass += " " + this.TextBoxCssClass;

            Controls.Add(textBox);

            //--dd end
            Controls.Add(new LiteralControl("</dd>"));
            //--dt end
            Controls.Add(new LiteralControl("</dt>"));
            //--dl end
            Controls.Add(new LiteralControl("</dl>"));

            //---------------- current language end------------------------------------

            //---------------- all languages ------------------------------------------

            string languagesStyleAttr = "style='display:block;'";

            if (!LanguagesShown)
            {
                languagesStyleAttr = "style='display:none;'";
            }

            string languagesClassAttr = "class='language lagn_choices'";

            if (IsLarge)
            {
                languagesClassAttr = "class='language lagn_desc_choices'";
            }

            //-- ul
            Controls.Add(new LiteralControl("<ul " + languagesClassAttr + " " + languagesStyleAttr + ">"));


            foreach (var language in Languages)
            {
                //--li
                jsStr = CANCEL_BUBBLE + @csm.GetPostBackEventReference(this, "SwitchLanguage$" + language.ID);
                Controls.Add(new LiteralControl("<li onclick=\"" + jsStr + "\">"));

                //--dl
                Controls.Add(new LiteralControl("<dl>"));
                //--dt
                Controls.Add(new LiteralControl("<dt>"));

                DictEntry entry = null;
                if (Content != null && Content.Contents != null)
                {
                    entry = Content.Contents.FirstOrDefault(e => e.LanguageID == language.ID);
                }


                Controls.Add(new LiteralControl("<img src=" + this.Page.ClientScript.GetWebResourceUrl(this.GetType(), String.Format(FLAG_RESOURCE_ROOT, language.Code.ToLower())) + ">"));
                Controls.Add(new LiteralControl("</img>"));

                Controls.Add(new LiteralControl("<span>" + language.Name + "</span>"));
                /*.Attributes["CurrentLanguageID"] = CurrentLanguage.ID.ToString();*/
                Controls.Add(new LiteralControl("<dd languageID=\"" + language.ID + "\">"));
                if (entry != null)
                {
                    Controls.Add(new LiteralControl(entry.Content));
                }
                Controls.Add(new LiteralControl("</dd>"));

                //--dt end
                Controls.Add(new LiteralControl("</dt>"));
                //--dl end
                Controls.Add(new LiteralControl("</dl>"));
                //--li end
                Controls.Add(new LiteralControl("</li>"));
            }

            //--ul end
            Controls.Add(new LiteralControl("</ul>"));

            if (IsTextBoxFocused)
            {
                Page.SetFocus(textBox);
            }
        }
		protected override void RenderAttributes (HtmlTextWriter writer)
		{
#if NET_2_0
			if (Page != null && Events [ServerClickEvent] != null) {
				PostBackOptions options = GetPostBackOptions ();
				Attributes ["onclick"] += Page.ClientScript.GetPostBackEventReference (options, true);
				writer.WriteAttribute ("language", "javascript");
			}
#else		
			ClientScriptManager csm = new ClientScriptManager (Page);
			bool postback = false;

			if (Page != null && Events [ServerClickEvent] != null)
				postback = true;

			if (CausesValidation && Page != null && Page.AreValidatorsUplevel ()) {
				if (postback)
					writer.WriteAttribute ("onclick",
							       String.Concat ("javascript:{if (typeof(Page_ClientValidate) != 'function' ||  Page_ClientValidate()) ",
									      csm.GetPostBackEventReference (this, String.Empty), "}"));
				else
					writer.WriteAttribute ("onclick",
							       "if (typeof(Page_ClientValidate) == 'function') Page_ClientValidate();");

				writer.WriteAttribute ("language", "javascript");
			}
			else if (postback) {
				writer.WriteAttribute ("onclick",
						       Page.ClientScript.GetPostBackClientHyperlink (this, ""));

				writer.WriteAttribute ("language", "javascript");
			}
#endif

			base.RenderAttributes (writer);
		}
        protected void Page_PreRender(object sender, EventArgs e)
        {
            bool createAuditAccess = SessionManager.CheckUserPrivilege(SysPriv.admin, SysScope.audit);


            if (IsPostBack)
            {
                RadPersistenceManager1.StorageProviderKey = SessionManager.UserContext.Person.PERSON_ID.ToString();
                RadPersistenceManager1.SaveState();

                if (SessionManager.ReturnStatus == true)
                {
                    if (SessionManager.ReturnObject is string)
                    {
                        string type = SessionManager.ReturnObject as string;
                        switch (type)
                        {
                        case "DisplayAudits":
                            UpdateDisplayState(DisplayState.AuditExceptionList);
                            break;

                            //case "Notification":
                            //	//UpdateDisplayState(DisplayState.AuditNotificationEdit);
                            //	//UpdateDisplayState(DisplayState.AuditReportEdit);
                            //	uclAuditForm.EditAuditId = SessionManager.ReturnRecordID;
                            //	UpdateDisplayState(DisplayState.AuditNotificationEdit);
                            //	if (isDirected)
                            //	{
                            //		rbNew.Visible = false;
                            //		uclAuditForm.EnableReturnButton(false);
                            //	}
                            //	break;

                            //case "Closed":
                            //	uclAuditForm.EditAuditId = SessionManager.ReturnRecordID;
                            //	UpdateDisplayState(DisplayState.AuditNotificationClosed);
                            //	if (isDirected)
                            //	{
                            //		rbNew.Visible = false;
                            //		uclAuditForm.EnableReturnButton(false);
                            //	}
                            //	break;
                            //case "DisplayOnly":
                            //	uclAuditForm.EditAuditId = SessionManager.ReturnRecordID;
                            //	UpdateDisplayState(DisplayState.AuditNotificationDisplay);
                            //	if (isDirected)
                            //	{
                            //		rbNew.Visible = false;
                            //		uclAuditForm.EnableReturnButton(false);
                            //	}
                            //	break;
                        }
                    }
                    SessionManager.ClearReturns();
                }
            }
            else
            {
                if (SessionManager.ReturnStatus == true && SessionManager.ReturnObject is string)
                {
                    try
                    {
                        // from inbox
                        DisplayNonPostback();
                        SessionManager.ReturnRecordID = Convert.ToDecimal(SessionManager.ReturnObject.ToString());
                        SessionManager.ReturnObject   = "Notification";
                        SessionManager.ReturnStatus   = true;

                        StringBuilder       sbScript = new StringBuilder();
                        ClientScriptManager cs       = Page.ClientScript;

                        sbScript.Append("<script language='JavaScript' type='text/javascript'>\n");
                        sbScript.Append("<!--\n");
                        sbScript.Append(cs.GetPostBackEventReference(this, "PBArg") + ";\n");
                        sbScript.Append("// -->\n");
                        sbScript.Append("</script>\n");

                        cs.RegisterStartupScript(this.GetType(), "AutoPostBackScript", sbScript.ToString());
                    }
                    catch
                    {
                        // not a number, parse as type
                        DisplayNonPostback();
                    }
                }
                else
                {
                    DisplayNonPostback();
                }
            }
        }
Example #28
0
        protected void Page_PreRender(object sender, EventArgs e)
        {
            bool createAuditAccess = SessionManager.CheckUserPrivilege(SysPriv.config, SysScope.audit);

            var sourceId = Page.Request[Page.postEventSourceID];

            if (IsPostBack)
            {
                if (!uclAssessmentForm.IsEditContext)
                {
                    RadPersistenceManager1.StorageProviderKey = SessionManager.UserContext.Person.PERSON_ID.ToString();
                    RadPersistenceManager1.SaveState();
                }

                if (SessionManager.ReturnStatus == true)
                {
                    if (SessionManager.ReturnObject is string)
                    {
                        string type        = SessionManager.ReturnObject as string;
                        string auditStatus = "";
                        switch (type)
                        {
                        case "DisplayAudits":
                            rbNew.Visible = createAuditAccess;
                            UpdateDisplayState(DisplayState.AuditList);
                            break;

                        case "Notification":
                            //UpdateDisplayState(DisplayState.AuditNotificationEdit);
                            //UpdateDisplayState(DisplayState.AuditReportEdit);
                            uclAssessmentForm.EditAuditId = SessionManager.ReturnRecordID;
                            // need to determine if the Audit is past due and force it into display mode (probelm when coming from Calendar)
                            auditStatus   = EHSAuditMgr.SelectAuditStatus(SessionManager.ReturnRecordID);
                            rbNew.Visible = false;
                            if (auditStatus == "C")
                            {
                                UpdateDisplayState(DisplayState.AuditNotificationDisplay);
                            }
                            else
                            {
                                UpdateDisplayState(DisplayState.AuditNotificationEdit);
                            }
                            if (isDirected)
                            {
                                uclAssessmentForm.EnableReturnButton(false);
                            }
                            break;

                        case "ReAudit":
                            decimal reauditId = CreateReAudit(SessionManager.ReturnRecordID);
                            if (reauditId > 0)
                            {
                                SessionManager.ReturnRecordID = reauditId;
                                uclAssessmentForm.EditAuditId = reauditId;
                                rbNew.Visible = false;
                                UpdateDisplayState(DisplayState.AuditNotificationEdit);

                                if (isDirected)
                                {
                                    uclAssessmentForm.EnableReturnButton(false);
                                }
                            }
                            else
                            {
                                // probably need to show some sort of error message...
                                rbNew.Visible = createAuditAccess;
                                UpdateDisplayState(DisplayState.AuditList);
                            }
                            break;

                        case "Closed":
                            uclAssessmentForm.EditAuditId = SessionManager.ReturnRecordID;
                            UpdateDisplayState(DisplayState.AuditNotificationClosed);
                            rbNew.Visible = false;
                            if (isDirected)
                            {
                                uclAssessmentForm.EnableReturnButton(false);
                            }
                            break;

                        case "DisplayOnly":
                            uclAssessmentForm.EditAuditId = SessionManager.ReturnRecordID;
                            UpdateDisplayState(DisplayState.AuditNotificationDisplay);
                            rbNew.Visible = false;
                            if (isDirected)
                            {
                                uclAssessmentForm.EnableReturnButton(false);
                            }
                            break;

                        case "AddAttachment":
                        case "AddTask":
                            //UpdateDisplayState(DisplayState.AuditNotificationEdit);
                            //UpdateDisplayState(DisplayState.AuditReportEdit);
                            uclAssessmentForm.EditAuditId = SessionManager.ReturnRecordID;
                            // need to determine if the Audit is past due and force it into display mode (probelm when coming from Calendar)
                            auditStatus   = EHSAuditMgr.SelectAuditStatus(SessionManager.ReturnRecordID);
                            rbNew.Visible = false;
                            if (auditStatus == "C")
                            {
                                UpdateDisplayState(DisplayState.AuditNotificationDisplay);
                            }
                            else
                            {
                                UpdateDisplayState(DisplayState.AuditNotificationEdit);
                            }
                            if (isDirected)
                            {
                                uclAssessmentForm.EnableReturnButton(false);
                            }
                            break;
                        }
                    }
                    SessionManager.ClearReturns();
                }
            }
            else
            {
                uclAssessmentForm.EditReturnState = "NeedsRefresh";
                if (SessionManager.ReturnStatus == true && SessionManager.ReturnObject is string)
                {
                    try
                    {
                        // from inbox
                        DisplayNonPostback();
                        SessionManager.ReturnRecordID = Convert.ToDecimal(SessionManager.ReturnObject.ToString());
                        SessionManager.ReturnObject   = "Notification";
                        SessionManager.ReturnStatus   = true;
                        isDirected = true;

                        StringBuilder       sbScript = new StringBuilder();
                        ClientScriptManager cs       = Page.ClientScript;

                        sbScript.Append("<script language='JavaScript' type='text/javascript'>\n");
                        sbScript.Append("<!--\n");
                        sbScript.Append(cs.GetPostBackEventReference(this, "PBArg") + ";\n");
                        sbScript.Append("// -->\n");
                        sbScript.Append("</script>\n");

                        cs.RegisterStartupScript(this.GetType(), "AutoPostBackScript", sbScript.ToString());
                    }
                    catch
                    {
                        // not a number, parse as type
                        DisplayNonPostback();
                    }
                }
                else
                {
                    DisplayNonPostback();
                }
            }
            // for now, we will only let 'admin' create audits
            //if (!SessionManager.UserContext.Person.SSO_ID.ToLower().Equals("admin"))
            //	rbNew.Visible = false;
            rbNew.Visible = createAuditAccess;
        }
Example #29
0
        protected void Page_PreRender(object sender, EventArgs e)
        {
            bool createAuditAccess = SessionManager.CheckUserPrivilege(SysPriv.originate, SysScope.audit);

            if (rbNew.Visible)
            {
                rbNew.Visible = createAuditAccess;
            }


            if (IsPostBack)
            {
                if (!uclAuditScheduleDetail.IsEditContext)
                {
                    RadPersistenceManager1.SaveState();
                }

                if (SessionManager.ReturnStatus == true)
                {
                    if (SessionManager.ReturnObject is string)
                    {
                        string type = SessionManager.ReturnObject as string;
                        switch (type)
                        {
                        case "DisplayAuditSchedules":
                            UpdateDisplayState(DisplayState.AuditScheduleList);
                            break;

                        case "Notification":
                            uclAuditScheduleDetail.EditAuditScheduleId = SessionManager.ReturnRecordID;
                            UpdateDisplayState(DisplayState.AuditScheduleEdit);
                            rbNew.Visible = false;
                            uclAuditScheduleDetail.EnableReturnButton(true);
                            break;

                        case "Closed":
                            uclAuditScheduleDetail.EditAuditScheduleId = SessionManager.ReturnRecordID;
                            UpdateDisplayState(DisplayState.AuditScheduleNew);
                            rbNew.Visible = false;
                            uclAuditScheduleDetail.EnableReturnButton(false);
                            break;
                        }
                    }
                    SessionManager.ClearReturns();
                }
            }
            else
            {
                if (SessionManager.ReturnStatus == true && SessionManager.ReturnObject is string)
                {
                    try
                    {
                        // from inbox
                        DisplayNonPostback();
                        SessionManager.ReturnRecordID = Convert.ToDecimal(SessionManager.ReturnObject.ToString());
                        SessionManager.ReturnObject   = "Notification";
                        SessionManager.ReturnStatus   = true;

                        StringBuilder       sbScript = new StringBuilder();
                        ClientScriptManager cs       = Page.ClientScript;

                        sbScript.Append("<script language='JavaScript' type='text/javascript'>\n");
                        sbScript.Append("<!--\n");
                        sbScript.Append(cs.GetPostBackEventReference(this, "PBArg") + ";\n");
                        sbScript.Append("// -->\n");
                        sbScript.Append("</script>\n");

                        cs.RegisterStartupScript(this.GetType(), "AutoPostBackScript", sbScript.ToString());
                    }
                    catch
                    {
                        // not a number, parse as type
                        DisplayNonPostback();
                    }
                }
                else
                {
                    DisplayNonPostback();
                }
            }
        }
        protected void Page_PreRender(object sender, EventArgs e)
        {
            accessLevel = UserContext.CheckAccess("EHS", "");
            if (accessLevel < AccessMode.Update)
            {
                rbNew.Visible = false;
            }

            if (IsPostBack)
            {
                if (!uclIncidentForm.IsEditContext)
                {
                    RadPersistenceManager1.SaveState();
                }

                if (SessionManager.ReturnStatus == true)
                {
                    if (SessionManager.ReturnObject is string)
                    {
                        string type = SessionManager.ReturnObject as string;
                        switch (type)
                        {
                        case "DisplayIncidents":
                            UpdateDisplayState(DisplayState.IncidentList);
                            break;

                        case "Notification":
                            //UpdateDisplayState(DisplayState.IncidentNotificationEdit);
                            //UpdateDisplayState(DisplayState.IncidentReportEdit);
                            uclIncidentForm.EditIncidentId = SessionManager.ReturnRecordID;
                            UpdateDisplayState(DisplayState.IncidentNotificationEdit);
                            if (isDirected)
                            {
                                rbNew.Visible = false;
                                uclIncidentForm.EnableReturnButton(false);
                            }
                            break;

                        case "Report":
                            uclIncidentForm.EditIncidentId = SessionManager.ReturnRecordID;
                            UpdateDisplayState(DisplayState.IncidentReportEdit);
                            break;
                        }
                    }
                    SessionManager.ClearReturns();
                }
            }
            else
            {
                if (SessionManager.ReturnStatus == true && SessionManager.ReturnObject is string)
                {
                    try
                    {
                        // from inbox
                        DisplayNonPostback();
                        SessionManager.ReturnRecordID = Convert.ToDecimal(SessionManager.ReturnObject.ToString());
                        SessionManager.ReturnObject   = "Notification";
                        SessionManager.ReturnStatus   = true;
                        isDirected = true;

                        StringBuilder       sbScript = new StringBuilder();
                        ClientScriptManager cs       = Page.ClientScript;

                        sbScript.Append("<script language='JavaScript' type='text/javascript'>\n");
                        sbScript.Append("<!--\n");
                        sbScript.Append(cs.GetPostBackEventReference(this, "PBArg") + ";\n");
                        sbScript.Append("// -->\n");
                        sbScript.Append("</script>\n");

                        cs.RegisterStartupScript(this.GetType(), "AutoPostBackScript", sbScript.ToString());
                    }
                    catch
                    {
                        // not a number, parse as type
                        DisplayNonPostback();
                    }
                }
                else
                {
                    DisplayNonPostback();
                }
            }
        }