protected void grdInventotyHistory_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { //if InventoryDropTypeId is sell then add the onClick event if (grdInventotyHistory.DataKeys[e.Row.RowIndex]["InventoryDropTypeId"] != DBNull.Value) { if (Convert.ToInt32(grdInventotyHistory.DataKeys[e.Row.RowIndex]["InventoryDropTypeId"]) == (int)DropType.Sell) { PostBackOptions postOptions = new PostBackOptions((Control)sender, "Select$" + e.Row.RowIndex.ToString()); String selectScript = Page.ClientScript.GetPostBackEventReference(postOptions); // // This for not uses equal, to not overbound the index // for (int a = 0; a < e.Row.Cells.Count; a++) { e.Row.Cells[a].Attributes.Add("onclick", selectScript); } } } //if (e.Row.RowIndex != 0) // e.Row.Cells[e.Row.Cells.Count - 1].Visible = false; //e.Row.Cells[e.Row.Cells.Count - 1].Attributes.Add("onclick", "event.cancelBubble=true;javascript:if(confirm('O registro será excluido e não poderá mais ser recuperado, deseja realmente efetuar a operação?') == false) return false;"); } }
protected void grdRoles_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { PostBackOptions postOptions = new PostBackOptions(this.grdRoles, "Select$" + e.Row.RowIndex.ToString()); String insertScript = ClientScript.GetPostBackEventReference(postOptions); // // This for not uses equal, to not overbound the index // for (int a = 0; a < e.Row.Cells.Count; a++) { e.Row.Cells[a].Attributes.Add("onclick", insertScript); } // // Cancel a nested event fires // if (Convert.ToString(grdRoles.DataKeys[e.Row.RowIndex]["Name"]).ToUpper().Contains("ADMIN")) e.Row.Cells[e.Row.Cells.Count - 1].Text = ""; else e.Row.Cells[e.Row.Cells.Count - 1].Attributes.Add("onclick", "event.cancelBubble=true;javascript:if(confirm('O registro será excluido e não poderá mais ser recuperado, deseja realmente efetuar a operação?') == false) return false;"); } }
void m_repMapRepeater_ItemDataBound(object sender, RepeaterItemEventArgs e) { TadImage oImageInfo = e.Item.DataItem as TadImage; LinkButton oLink = e.Item.FindControl("m_lbName") as LinkButton; oLink.Text = oImageInfo.Title; oLink.PostBackUrl = "ViewMap.aspx?ImageId=" + oImageInfo.Id; Label oLabel = e.Item.FindControl("m_lblDescription") as Label; oLabel.Text = oImageInfo.Description; Image oImage = e.Item.FindControl("m_imgImage") as Image; oImage.Width = 80; oImage.Height = 80; PostBackOptions options = new PostBackOptions(oLink, "", "ViewMap.aspx?ImageId=" + oImageInfo.Id, true, false, false, true, false, ""); HtmlControl oDiv = e.Item.FindControl("ListItem") as HtmlControl; oDiv.Attributes.Add("onClick", ClientScript.GetPostBackEventReference(options)); oDiv.Attributes.Add("onMouseOver", "this.style.background = '#FFFFCC';"); oDiv.Attributes.Add("onMouseOut", "this.style.background = '#FFFFFF';"); ThreeSharpWrapper s3 = new ThreeSharpWrapper(S3Storage.AccessKey, S3Storage.SecretAccessKey); oImage.ImageUrl = s3.GetUrl(S3Storage.BucketName, "Square_" + oImageInfo.StorageKey); //oImage.ImageUrl = "http://" + S3Storage.BucketName + ".s3.amazonaws.com/Square_" + oImageInfo.StorageKey; }
protected void grdComposites_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { var postOptions = new PostBackOptions(grdComposites, "Select$" + e.Row.RowIndex); e.Row.Cells[e.Row.Cells.Count - 1].Attributes.Add("onclick", "event.cancelBubble=true;javascript:if(confirm('O registro será excluido e não poderá mais ser recuperado, deseja realmente efetuar a operação?') == false) return false;"); } }
protected void Page_Load(object sender, EventArgs e) { if (((CareerCruisingWeb.PageBase.IndividualBase)Page).IsArchived || ((CareerCruisingWeb.PageBase.SuperBase)Page).ToolTypeID == "2") { loginID = CareerCruisingWeb.CCLib.Common.Strings.GetQueryString("LoginID"); // get database name ((CareerCruisingWeb.PageBase.IndividualBase)Page).DatabaseName = CareerCruisingWeb.CCLib.Common.Strings.GetDatabaseName(); //generate values dtFinancialSelectorList = CareerCruisingWeb.CCLib.Common.DataAccess.GetDataTable("select SelectorID,SelectorCriteria,SelectorType from " + ((CareerCruisingWeb.PageBase.IndividualBase)Page).DatabaseName + "Port_Selector where PortfolioID=" + strPortfolioID + " and (SelectorType='FA' OR SelectorType='LocalSchol')"); if (dtFinancialSelectorList.Rows.Count > 0) for (int i = 0; i < dtFinancialSelectorList.Rows.Count; i++) { if (dtFinancialSelectorList.Rows[i]["SelectorType"].ToString() == "FA" && !booHasFASelector) { booHasFASelector = true; // set the "View Results" link to postback to the "/Individual/ViewSelector.aspx" page //SelectorType.Value = "FASelector"; //SelectorValue.Value = dtFinancialSelectorList.Rows[i]["SelectorCriteria"].ToString(); //PostBackOptions postBackOptions = new PostBackOptions(hlViewFA); //postBackOptions.ActionUrl = "/Individual/ViewSelector.aspx?LoginID=" + loginID; //hlViewFA.Attributes.Add("onclick", ((CareerCruisingWeb.PageBase.IndividualBase)Page).ClientScript.GetPostBackEventReference(postBackOptions)); //hlViewFA.NavigateUrl = Request.Url.ToString() + "#/"; //hlDelFA.Attributes.Add("SelectorID", dtFinancialSelectorList.Rows[i]["SelectorID"].ToString()); intFA = i; //Response.Write("SelectorType: " + SelectorValue.Value); } else if (dtFinancialSelectorList.Rows[i]["SelectorType"].ToString() == "LocalSchol" && !booHasLocalScholSelector) { booHasLocalScholSelector = true; // set the "View Results" link to postback to the "/USSchool/LocalScholarships/SearchFinderResults.aspx" page hfLSSelectorCriteria.Value = dtFinancialSelectorList.Rows[i]["SelectorCriteria"].ToString(); PostBackOptions postBackOptions = new PostBackOptions(hlViewLocalSchol); postBackOptions.ActionUrl = "/USSchool/LocalScholarships/SearchFinderResults.aspx?LoginID=" + loginID; hlViewLocalSchol.Attributes.Add("onclick", ((CareerCruisingWeb.PageBase.IndividualBase)Page).ClientScript.GetPostBackEventReference(postBackOptions)); hlViewLocalSchol.NavigateUrl = Request.Url.ToString() + "#/"; intLocalSchol = i; //hlDelLocalSchol.Attributes.Add("SelectorID", dtFinancialSelectorList.Rows[i]["SelectorID"].ToString()); } } tr1.Visible = booHasFASelector; tr3.Visible = !booHasFASelector; // Only users who have access to the "Application Planner" and "Local Scholarship" can access the Search Finder tr2.Visible = (booShowLocalSchol) ? booHasLocalScholSelector : false; tr4.Visible = (booShowLocalSchol) ? !booHasLocalScholSelector : false; // If the user goes at the form "/USSchool/LocalScholarships/SearchFinder" from the link on this page, then the form should be empty Session["LocalScholSelectorCriteria"] = ""; DataBind(); } }
protected override PostBackOptions GetPostBackOptions() { // _owner.Page may be null in the designer if (!String.IsNullOrEmpty(_eventArgument) && _owner.Page != null) { PostBackOptions options = new PostBackOptions(_owner, _eventArgument); options.ClientSubmit = true; return options; } return base.GetPostBackOptions(); }
protected void grdEquipments_RowDataBound1(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { PostBackOptions postOptions = new PostBackOptions(grdEquipments, "Select$" + e.Row.RowIndex.ToString()); string insertScript = Page.ClientScript.GetPostBackEventReference(postOptions); for (int a = 0; a < (e.Row.Cells.Count - 2); a++) e.Row.Cells[a].Attributes.Add("onclick", insertScript); e.Row.Cells[e.Row.Cells.Count - 1].Attributes.Add("onclick", "event.cancelBubble == true;javascript:if(confirm('Deseja realmente apagar a linha solicitada') == false)return false;"); } }
/// <summary> /// Registers a function which can be called to simulate next and back btn click /// </summary> private void RegisterNextScript() { PostBackOptions backOptions = new PostBackOptions(BackBtn); string backServerScript = Page.ClientScript.GetPostBackEventReference(backOptions); string backScript = "function goBack() { " + backServerScript + " } "; Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "goBack", backScript, true); PostBackOptions nextOptions = new PostBackOptions(NextBtn); string forwardServerScript = Page.ClientScript.GetPostBackEventReference(nextOptions); string forwardScript = "function goForward() { " + forwardServerScript + " } "; Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "goForward", forwardScript, true); }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { _idx = Session["UserId"].ToString(); LoadData(); MultiView1.ActiveViewIndex = 0; } Page.Header.DataBind(); PostBackOptions optionsSubmit = new PostBackOptions(btnOkay); btnOkay.OnClientClick = "disableButtonOnClick(this, 'Please wait...', 'disabled_button'); "; btnOkay.OnClientClick += ClientScript.GetPostBackEventReference(optionsSubmit); }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { _idx = Convert.ToInt32(Request.QueryString["idx"]); LoadData(); MultiView1.ActiveViewIndex = 0; } PostBackOptions optionsSubmit = new PostBackOptions(btnOkay); btnOkay.OnClientClick = "disableButtonOnClick(this, 'Please wait...', 'disabled_button'); "; btnOkay.OnClientClick += ClientScript.GetPostBackEventReference(optionsSubmit); }
protected override void RenderContents(HtmlTextWriter output) { PostBackOptions p = new PostBackOptions(this); output.AddAttribute(HtmlTextWriterAttribute.Onclick, Page.ClientScript.GetPostBackEventReference(p)); output.AddAttribute(HtmlTextWriterAttribute.Id, this.ClientID + "_i"); output.AddAttribute(HtmlTextWriterAttribute.Name, this.ClientID + "_i"); output.RenderBeginTag(HtmlTextWriterTag.Button); output.Write("My Button"); output.RenderEndTag(); }
protected virtual PostBackOptions GetPostBackOptions(string argument) { var postBackOptions = new PostBackOptions(this, argument) { RequiresJavaScriptProtocol = true }; if (this.CausesValidation && this.Page.GetValidators(this.ValidationGroup).Count > 0) { postBackOptions.PerformValidation = true; postBackOptions.ValidationGroup = this.ValidationGroup; } return(postBackOptions); }
protected override void OnInit(EventArgs e) { _p = new PostBackOptions(this); _ValidationState(this._performValidation); _ValidationGroupState(this._validationGroup); _Panel = new Panel(); _Panel.CssClass = "RibbonItems RibbonItems_SmallItem"; _Panel.Attributes.Add("ItemID", this.ID); this.Controls.Add(_Panel); if (this._enabled) { _Panel.Attributes.Add("onclick", this._clientClick + "; " + Page.ClientScript.GetPostBackEventReference(_p)); } if (this._width != null) { _Panel.Style.Add("width", _width.ToString()); } _EnableState(this._enabled); _CheckedState(this._checked); if (!String.IsNullOrEmpty(this._tooltip)) { _Panel.CssClass += " RibbonItemWithTooltip"; _Panel.Attributes.Add("tooltip", this._tooltip); } Table lTable = new Table(); _Panel.Controls.Add(lTable); TableRow lTableRow = new TableRow(); lTable.Controls.Add(lTableRow); TableCell lTableCell = new TableCell(); lTableRow.Controls.Add(lTableCell); Image lImage = new Image(); lImage.ImageUrl = (!String.IsNullOrEmpty(this._imageurl)) ? this._imageurl : Page.ClientScript.GetWebResourceUrl(this.GetType(), "OfficeWebUI.Resources.Common.Image.blank.gif"); lImage.Width = 16; lImage.Height = 16; lTableCell.Controls.Add(lImage); base.OnInit(e); }
private PostBackOptions GetPostBackOptions() { PostBackOptions options = new PostBackOptions(this, string.Empty); options.RequiresJavaScriptProtocol = true; if (CausesValidation && Page.GetValidators(ValidationGroup).Count > 0) { options.PerformValidation = true; options.ValidationGroup = ValidationGroup; } return(options); }
internal virtual string GetClientScriptEventReference() { PostBackOptions options = GetPostBackOptions(); Page page = Page; if (page != null) { return(page.ClientScript.GetPostBackEventReference(options, true)); } else { return(String.Empty); } }
protected override void AddAttributesToRender(HtmlTextWriter w) { if (Page != null) { Page.VerifyRenderingInServerForm(this); } #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, "")); } #endif }
protected void grdEquipments_RowDataBound1(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { PostBackOptions postOptions = new PostBackOptions(grdEquipments, "Select$" + e.Row.RowIndex.ToString()); string insertScript = Page.ClientScript.GetPostBackEventReference(postOptions); for (int a = 0; a < (e.Row.Cells.Count - 2); a++) { e.Row.Cells[a].Attributes.Add("onclick", insertScript); } e.Row.Cells[e.Row.Cells.Count - 1].Attributes.Add("onclick", "event.cancelBubble == true;javascript:if(confirm('Deseja realmente apagar a linha solicitada') == false)return false;"); } }
protected void Button1_Click(object sender, EventArgs e) { // Create a new PostBackOptions object and set its properties. PostBackOptions myPostBackOptions = new PostBackOptions(this); myPostBackOptions.ActionUrl = "Page2.aspx"; myPostBackOptions.AutoPostBack = false; myPostBackOptions.RequiresJavaScriptProtocol = true; myPostBackOptions.PerformValidation = true; // Add the client-side script to the HyperLink1 control. HyperLink1.NavigateUrl = Page.ClientScript.GetPostBackEventReference(myPostBackOptions); Label1.Text = "Click this hyperlink to initiate a postback event."; }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { //PopulatePortal2DDL(); LoadPassQuestion2DDL(); MultiView1.ActiveViewIndex = 0; } PostBackOptions optionsSubmit = new PostBackOptions(btnOkay); btnOkay.OnClientClick = "disableButtonOnClick(this, 'Please wait...', 'disabled_button'); "; btnOkay.OnClientClick += ClientScript.GetPostBackEventReference(optionsSubmit); //btnOkay.OnClientClick = String.Format("this.disabled=true; __doPostBack('{0}','');", btnOkay.UniqueID); }
protected void gvDetails_RowDataBound(object sender, GridViewRowEventArgs e) { //加以下這段為選擇行 PostBackOptions myPostBackOptions = new PostBackOptions(this); myPostBackOptions.AutoPostBack = false; myPostBackOptions.RequiresJavaScriptProtocol = true; myPostBackOptions.PerformValidation = false; String evt = Page.ClientScript.GetPostBackClientHyperlink(sender as GridView, "Select$" + e.Row.RowIndex.ToString()); e.Row.Attributes.Add("onclick", evt); e.Row.Attributes.Add("onMouseOver", "Color=this.style.backgroundColor;this.style.backgroundColor='lightBlue'"); e.Row.Attributes.Add("onMouseOut", "this.style.backgroundColor=Color;"); }
/// <summary> /// Retorna o JavaScript necessário para invocar o evento OnSelect /// </summary> /// <param name="idLider">O ID do ProdutoVO que será passado como parâmetro para o evento</param> /// <returns>O JavaScript</returns> protected string GetOnSelectEvent(object idLider) { if (OnSelect != null && idLider != null) { PostBackOptions options = new PostBackOptions(this); options.Argument = idLider.ToString(); string postBackReference = Page.ClientScript.GetPostBackEventReference(options); return("checkOnlyOne(this,'idLider');" + postBackReference + ";"); } return("checkOnlyOne(this,'idLider');"); }
private void RenderEditModeValue( BocAutoCompleteReferenceValueRenderingContext renderingContext, TextBox textBox, HiddenField hiddenField, bool isControlHeightEmpty, bool isDropDownListHeightEmpty, bool isDropDownListWidthEmpty) { renderingContext.Writer.AddStyleAttribute(HtmlTextWriterStyle.Width, "100%"); renderingContext.Writer.AddAttribute(HtmlTextWriterAttribute.Class, CssClassContent); renderingContext.Writer.RenderBeginTag(HtmlTextWriterTag.Td); // Begin td if (!isControlHeightEmpty && isDropDownListHeightEmpty) { renderingContext.Writer.AddStyleAttribute(HtmlTextWriterStyle.Height, "100%"); } if (isDropDownListWidthEmpty) { renderingContext.Writer.AddStyleAttribute(HtmlTextWriterStyle.Width, "100%"); } bool autoPostBack = textBox.AutoPostBack; textBox.AutoPostBack = false; textBox.RenderControl(renderingContext.Writer); textBox.AutoPostBack = autoPostBack; if (autoPostBack) { PostBackOptions options = new PostBackOptions(textBox, string.Empty); if (textBox.CausesValidation) { options.PerformValidation = true; options.ValidationGroup = textBox.ValidationGroup; } if (renderingContext.Control.Page.Form != null) { options.AutoPostBack = true; } var postBackEventReference = renderingContext.Control.Page.ClientScript.GetPostBackEventReference(options, true); renderingContext.Writer.AddAttribute(HtmlTextWriterAttribute.Onchange, postBackEventReference); } hiddenField.RenderControl(renderingContext.Writer); renderingContext.Writer.RenderEndTag(); // End td RenderEditModeValueExtension(renderingContext); }
/// <summary> /// Writes the submit panel. /// </summary> /// <param name="writer"> /// The writer. /// </param> /// <param name="changePwd"> /// The change PWD. /// </param> /// <remarks> /// </remarks> private void WriteSubmitPanel(HtmlTextWriter writer, ChangePassword changePwd) { WebControlAdapterExtender.WriteBeginDiv(writer, "AspNet-ChangePassword-SubmitPanel", string.Empty); var id = "ChangePassword"; id += (changePwd.ChangePasswordButtonType == ButtonType.Button) ? "Push" : string.Empty; var idWithType = WebControlAdapterExtender.MakeIdWithButtonType(id, changePwd.ChangePasswordButtonType); var btn = changePwd.ChangePasswordTemplateContainer.FindControl(idWithType); if (btn != null) { this.Page.ClientScript.RegisterForEventValidation(btn.UniqueID); var options = new PostBackOptions( btn, string.Empty, string.Empty, false, false, false, true, true, changePwd.UniqueID); var javascript = "javascript:" + this.Page.ClientScript.GetPostBackEventReference(options); javascript = this.Page.Server.HtmlEncode(javascript); this.Extender.WriteSubmit( writer, changePwd.ChangePasswordButtonType, changePwd.ChangePasswordButtonStyle.CssClass, changePwd.ChangePasswordTemplateContainer.ID + "_" + id, changePwd.ChangePasswordButtonImageUrl, javascript, changePwd.ChangePasswordButtonText); } id = "Cancel"; id += (changePwd.ChangePasswordButtonType == ButtonType.Button) ? "Push" : string.Empty; idWithType = WebControlAdapterExtender.MakeIdWithButtonType(id, changePwd.CancelButtonType); btn = changePwd.ChangePasswordTemplateContainer.FindControl(idWithType); if (btn != null) { this.Page.ClientScript.RegisterForEventValidation(btn.UniqueID); this.Extender.WriteSubmit( writer, changePwd.CancelButtonType, changePwd.CancelButtonStyle.CssClass, changePwd.ChangePasswordTemplateContainer.ID + "_" + id, changePwd.CancelButtonImageUrl, string.Empty, changePwd.CancelButtonText); } WebControlAdapterExtender.WriteEndDiv(writer); }
protected override void OnInit(EventArgs e) { PostBackOptions p = new PostBackOptions(this); this._panel = new Panel(); this._panel.ID = _src.ID + "_p"; this._panel.Attributes.Add("WorkspaceInternalID", _src.ID); this._panel.CssClass = "OfficeWebUI_WorkspaceItem"; this.Controls.Add(_panel); this._panel.Attributes.Add("onclick", "OfficeWebUI.Workspace.SaveLastItem(\"" + _src.ID + "\"); " + _src.ClientClick + "; " + Page.ClientScript.GetPostBackEventReference(p)); Table lTable = new Table(); lTable.CellPadding = 2; lTable.CellSpacing = 0; this._panel.Controls.Add(lTable); TableRow lTableRow = new TableRow(); lTable.Controls.Add(lTableRow); TableCell lTableCellImage = new TableCell(); lTableRow.Controls.Add(lTableCellImage); Image lImage = new Image(); lImage.ImageUrl = (!String.IsNullOrEmpty(_src.ImageUrl)) ? _src.ImageUrl : Page.ClientScript.GetWebResourceUrl(this.GetType(), "OfficeWebUI.Resources.Common.Image.blank.gif"); lImage.Width = 16; lImage.Height = 16; lTableCellImage.Controls.Add(lImage); TableCell lTableCellText = new TableCell(); lTableRow.Controls.Add(lTableCellText); Literal lText = new Literal(); lText.Text = _src.Text; lTableCellText.Controls.Add(lText); //_panel.Controls.Add(new Literal { Text = _src.Text }); base.OnInit(e); }
PostBackOptions IPostBackContainer.GetPostBackOptions(IButtonControl buttonControl) { if (buttonControl == null) { throw new ArgumentNullException("buttonControl"); } if (buttonControl.CausesValidation) { throw new InvalidOperationException(SR.GetString("CannotUseParentPostBackWhenValidating", new object[] { base.GetType().Name, ID })); } PostBackOptions options = new PostBackOptions(this, buttonControl.CommandName + "$" + buttonControl.CommandArgument); options.RequiresJavaScriptProtocol = true; return(options); }
protected override void RenderAttributes(HtmlTextWriter writer) { if (base.Events[EventServerClick] != null) { base.Attributes.Remove("href"); base.RenderAttributes(writer); PostBackOptions postBackOptions = this.GetPostBackOptions(); string postBackEventReference = this.Page.ClientScript.GetPostBackEventReference(postBackOptions, true); writer.WriteAttribute("href", postBackEventReference, true); } else { base.PreProcessRelativeReferenceAttribute(writer, "href"); base.RenderAttributes(writer); } }
PostBackOptions GetPostBackOptions() { PostBackOptions options = new PostBackOptions(this); options.ValidationGroup = null; options.ActionUrl = null; options.Argument = String.Empty; options.RequiresJavaScriptProtocol = false; options.ClientSubmit = (0 != String.Compare(Type, "submit", true, Helpers.InvariantCulture)); options.PerformValidation = CausesValidation && Page != null && Page.Validators.Count > 0; if (options.PerformValidation) { options.ValidationGroup = ValidationGroup; } return(options); }
protected override void Render(HtmlTextWriter writer) { List <Control> iconAndTextControls = new List <Control>(); if (this.Icon != null && this.IconPosition == Position.Left) { iconAndTextControls.Add(Icon); } iconAndTextControls.Add(new LiteralControl(this.Text)); if (this.Icon != null && this.IconPosition == Position.Right) { iconAndTextControls.Add(Icon); } string onClick = ""; if (Page != null) { if (CausesValidation || ValidationGroup.IsSet()) { PostBackOptions options = new PostBackOptions(this); options.ValidationGroup = this.ValidationGroup; options.PerformValidation = true; onClick = Page.ClientScript.GetPostBackEventReference(options, true); } else { onClick = Page.ClientScript.GetPostBackClientHyperlink(this, ""); } } writer.WriteHtmlElement(new HtmlElement( type: Type, attributes: new HtmlAttribute[] { new HtmlClassAttribute(CssClass, Size.ToRender(), CssStyle.ToRender()), new HtmlTypeAttribute("submit"), new HtmlNameAttribute(this.UniqueID), new HtmlAttribute("disabled", "disabled", !IsEnabled), new HtmlAttribute("data-toggle", "button", IsToggleable), new HtmlAttribute("onclick", onClick, !UseSubmitBehavior) }, controls: iconAndTextControls.ToArray() )); }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { _idx = Convert.ToInt32(Request.QueryString["idx"]); LoadControlTypeList2DDL(); Modules module_obj = new Modules(); Literal_ModuleName.Text = module_obj.GetModuleTitleByModuleId(_idx); MultiView1.ActiveViewIndex = 0; } PostBackOptions optionsSubmit = new PostBackOptions(btnOkay); btnOkay.OnClientClick = "disableButtonOnClick(this, 'Please wait...', 'disabled_button'); "; btnOkay.OnClientClick += ClientScript.GetPostBackEventReference(optionsSubmit); }
PostBackOptions GetPostBackOptions() { PostBackOptions options = new PostBackOptions(this); options.ActionUrl = null; options.ValidationGroup = null; options.Argument = String.Empty; options.RequiresJavaScriptProtocol = false; options.ClientSubmit = true; options.PerformValidation = CausesValidation && Page != null && Page.AreValidatorsUplevel(ValidationGroup); if (options.PerformValidation) { options.ValidationGroup = ValidationGroup; } return(options); }
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 override void AddAttributesToRender(HtmlTextWriter writer) { if (this.Page != null) { this.Page.VerifyRenderingInServerForm(this); } if (this.IsMultiSelectInternal) { writer.AddAttribute(HtmlTextWriterAttribute.Multiple, "multiple"); } if ((this.AutoPostBack && (this.Page != null)) && this.Page.ClientSupportsJavaScript) { string str = null; if (base.HasAttributes) { str = base.Attributes["onchange"]; if (str != null) { str = Util.EnsureEndWithSemiColon(str); base.Attributes.Remove("onchange"); } } PostBackOptions options = new PostBackOptions(this, string.Empty); if (this.CausesValidation) { options.PerformValidation = true; options.ValidationGroup = this.ValidationGroup; } if (this.Page.Form != null) { options.AutoPostBack = true; } str = Util.MergeScript(str, this.Page.ClientScript.GetPostBackEventReference(options, true)); writer.AddAttribute(HtmlTextWriterAttribute.Onchange, str); if (base.EnableLegacyRendering) { writer.AddAttribute("language", "javascript", false); } } if (this.Enabled && (!base.IsEnabled & this.SupportsDisabledAttribute)) { writer.AddAttribute(HtmlTextWriterAttribute.Disabled, "disabled"); } base.AddAttributesToRender(writer); }
protected virtual PostBackOptions GetPostBackOptions() { PostBackOptions options = new PostBackOptions(this, string.Empty) { ClientSubmit = false }; if (!string.IsNullOrEmpty(this.PostBackUrl)) { options.ActionUrl = HttpUtility.UrlPathEncode(base.ResolveClientUrl(this.PostBackUrl)); } if ((this.CausesValidation && (this.Page != null)) && (this.Page.GetValidators(this.ValidationGroup).Count > 0)) { options.PerformValidation = true; options.ValidationGroup = this.ValidationGroup; } return(options); }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { PopulateMediaTypeList2DDL(); PopulateMediaTopicList2DDL(); PopulateMediaAlbumList2DDL(); PopulateMediaArtistList2DDL(); PopulateMediaComposerList2DDL(); PopulateMediaPlayList2DDL(); MultiView1.ActiveViewIndex = 0; } PostBackOptions optionsSubmit = new PostBackOptions(btnOkay); btnOkay.OnClientClick = "disableButtonOnClick(this, 'Please wait...', 'disabled_button'); "; btnOkay.OnClientClick += ClientScript.GetPostBackEventReference(optionsSubmit); }
internal virtual string GetClientScriptEventReference() { PostBackOptions options = GetPostBackOptions(); Page page = Page; if (options.PerformValidation || !String.IsNullOrEmpty(options.ActionUrl)) { return(page != null?page.ClientScript.GetPostBackEventReference(options, true) : String.Empty); } else { if (page != null) { page.ClientScript.RegisterForEventValidation(options); } return(String.Empty); } }
PostBackOptions GetPostBackOptions(string argument) { if (postBackOptions == null) { postBackOptions = new PostBackOptions(this); postBackOptions.ActionUrl = null; postBackOptions.ValidationGroup = null; postBackOptions.RequiresJavaScriptProtocol = true; postBackOptions.ClientSubmit = true; postBackOptions.PerformValidation = CausesValidation && Page != null && Page.AreValidatorsUplevel(ValidationGroup); if (postBackOptions.PerformValidation) { postBackOptions.ValidationGroup = ValidationGroup; } } postBackOptions.Argument = argument; return(postBackOptions); }
/// <summary> /// GridView数据绑定 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void cityGridView_RowDataBound(object sender, GridViewRowEventArgs e) { e.Row.Attributes["style"] = "cursor:pointer"; PostBackOptions myPostBackOptions = new PostBackOptions(this); myPostBackOptions.AutoPostBack = false; myPostBackOptions.PerformValidation = false; myPostBackOptions.RequiresJavaScriptProtocol = true; //加入javascript:头 String evt = Page.ClientScript.GetPostBackClientHyperlink(sender as GridView, "Select$" + e.Row.RowIndex.ToString()); e.Row.Attributes.Add("onclick", evt); //后加的 //e.Row.Attributes.Add("onfocus", "currentcolor=this.style.backgroundColor;this.style.backgroundColor='#5cc5f2'"); //e.Row.Attributes.Add("onblur", "this.style.backgroundColor=currentcolor"); e.Row.Attributes.Add("onmouseover", "currentcolor=this.style.backgroundColor;this.style.backgroundColor='#5cc5f2'"); e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=currentcolor"); }
protected void grvServices_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { e.Row.Attributes["onclick"] = "location='Service.aspx?ServiceId=" + e.Row.DataItem.GetPropertyValue("ServiceId") + "';"; PostBackOptions postOptions = new PostBackOptions(this.grvServices, "Select$" + e.Row.RowIndex.ToString()); String insertScript = ClientScript.GetPostBackEventReference(postOptions); // // This for not uses equal, to not overbound the index // for (int a = 0; a < e.Row.Cells.Count; a++) { e.Row.Cells[a].Attributes.Add("onclick", insertScript); } // // Cancel a nested event fires // e.Row.Cells[e.Row.Cells.Count - 1].Attributes.Add("onclick", "event.cancelBubble=true;javascript:if(confirm('O registro será excluido e não poderá mais ser recuperado, deseja realmente efetuar a operação?') == false) return false;"); } }
PostBackOptions GetPostBackOptions (string argument) { if (postBackOptions == null) { postBackOptions = new PostBackOptions (this); postBackOptions.ActionUrl = null; postBackOptions.ValidationGroup = null; postBackOptions.RequiresJavaScriptProtocol = true; postBackOptions.ClientSubmit = true; postBackOptions.PerformValidation = CausesValidation && Page != null && Page.AreValidatorsUplevel (ValidationGroup); if (postBackOptions.PerformValidation) postBackOptions.ValidationGroup = ValidationGroup; } postBackOptions.Argument = argument; return postBackOptions; }
private void EnsureRefreshScript() { PostBackOptions options = new PostBackOptions(this) { PerformValidation = false }; string postback = ControlsHelper.GetPostBackEventReference(menu, options, false, true); string externalRefreshScript = null; if (!string.IsNullOrEmpty(OnClientStepChanged)) { externalRefreshScript = string.Format("clearInterval(refTimerId_{0}); {1};", ClientID, OnClientStepChanged); } string commonScript = @" String.prototype.startsWith = function (str) { return (this.match('^' + str) == str); }; function VerifyData(incomingData) { if (incomingData.startsWith('" + CALLBACK_ID + @"')) { return incomingData.replace('" + CALLBACK_ID + @"', ''); } else { data = null; } return data; } "; ScriptHelper.RegisterStartupScript(Page, typeof(string), "refCommon", commonScript, true); StringBuilder sb = new StringBuilder(); sb.Append(@" var refTimerId_", ClientID, @" = 0; function RfMenu_DoPostBack_", ClientID, @"() {", postback, @"} function RfMenu_Succ_", ClientID, @"(data, textStatus, jqXHR) { if(data != null) { var hdn = document.getElementById('", hdnParam.ClientID, @"'); var args = data.split('", CALLBACK_SEP, @"'); var stop = (args[1] == 'false'); var stepId = args[2]; if(stop) { clearInterval(refTimerId_", ClientID, @"); setTimeout('RfMenu_DoPostBack_", ClientID, "()', ", RefreshInterval, @"); } else { // Step changed if(hdn.value != stepId) { var lbl = document.getElementById('", AutomationManager.AutomationInfoLabel.ClientID, @"'); if(lbl != null) { lbl.innerHTML = args[0]; }", externalRefreshScript, @" } } hdn.value = stepId; } else { clearInterval(refTimerId_", ClientID, @"); setTimeout('RfMenu_DoPostBack_", ClientID, "()', ", RefreshInterval, @"); } } function RfMenu_Err_", ClientID, @"(jqXHR, textStatus, errorThrown) { var err = ''; if ((errorThrown != undefined) && (errorThrown != null) && (errorThrown != '')) { err = ' (' + errorThrown + ')'; clearInterval(refTimerId_", ClientID, @"); alert(err); } } function RfMenu_", ClientID, @"() { $cmsj.ajax({ cache: false, type: 'POST', data: 'params=", CALLBACK_ID + ClientID, CALLBACK_SEP, AutomationManager.ObjectType, CALLBACK_SEP, AutomationManager.ObjectID, CALLBACK_SEP, @"', context: document.body, success: RfMenu_Succ_" + ClientID, @", error: RfMenu_Err_", ClientID, @", dataType: 'text', dataFilter: VerifyData }); } refTimerId_", ClientID, @" = setInterval('RfMenu_", ClientID, "()', 200);"); ScriptHelper.RegisterStartupScript(Page, typeof(string), "ref_" + ClientID, sb.ToString(), true); }
protected override void Render(HtmlTextWriter writer) { base.Render(writer); PostBackOptions opt = new PostBackOptions(this, null) { PerformValidation = false }; Page.ClientScript.RegisterForEventValidation(opt); }
protected void grdServiceOrder_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { PostBackOptions postOptions = new PostBackOptions((frmEquipment.FindControl("grdServiceOrder") as GridView), "Select$" + e.Row.RowIndex.ToString()); String insertScript = Page.ClientScript.GetPostBackEventReference(postOptions); for (int a = 0; a < e.Row.Cells.Count; a++) e.Row.Cells[a].Attributes.Add("onclick", insertScript); } }
public string GetPostBackEventReference(PostBackOptions options) {}
/// <summary> /// 到货物料列表呈现前事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void grvMateriel_PreRender(object sender, EventArgs e) { //控制数据行样式 foreach (GridViewRow row in grvMateriel.Rows) { PostBackOptions myPostBackOptions = new PostBackOptions(this.grvMateriel); myPostBackOptions.AutoPostBack = false; myPostBackOptions.PerformValidation = false; myPostBackOptions.RequiresJavaScriptProtocol = true; //加入javascript:头 String evt = Page.ClientScript.GetPostBackClientHyperlink(sender as GridView, "Select$" + row.RowIndex.ToString()); row.Attributes.Add("onclick", evt); } }
protected virtual PostBackOptions GetPostBackOptions () { PostBackOptions options = new PostBackOptions (this); Page page = Page; options.ActionUrl = (PostBackUrl.Length > 0 ? #if TARGET_J2EE CreateActionUrl (PostBackUrl) #else (page != null ? page.ResolveClientUrl (PostBackUrl) : null) #endif : null); options.Argument = String.Empty; options.ClientSubmit = true; options.RequiresJavaScriptProtocol = true; options.PerformValidation = CausesValidation && page != null && page.AreValidatorsUplevel (ValidationGroup); if (options.PerformValidation) options.ValidationGroup = ValidationGroup; else options.ValidationGroup = null; return options; }
protected virtual PostBackOptions GetPostBackOptions () { PostBackOptions options = new PostBackOptions (this); options.ActionUrl = (PostBackUrl.Length > 0 ? Page.ResolveClientUrl (PostBackUrl) : null); options.ValidationGroup = null; options.Argument = String.Empty; options.RequiresJavaScriptProtocol = false; options.ClientSubmit = !UseSubmitBehavior; Page page = Page; options.PerformValidation = CausesValidation && page != null && page.AreValidatorsUplevel (ValidationGroup); if (options.PerformValidation) options.ValidationGroup = ValidationGroup; return options; }
protected override void Render(HtmlTextWriter writer) { if ((Context != null) && RenderContainer) { string cssClass = (UseBasicStyles || IsLiveSite) ? "PageHeaderLine" : "CMSEditMenu"; writer.Write(string.Format("<div class\"{0}\">", cssClass)); } base.Render(writer); if ((Context != null) && RenderContainer) { writer.Write("</div>"); } if (shortcutAction != null) { PostBackOptions opt = new PostBackOptions(this, shortcutAction.CommandArgument) { PerformValidation = true, ValidationGroup = shortcutAction.ValidationGroup }; Page.ClientScript.RegisterForEventValidation(opt); } }
private CMSButtonAction GetControlAction(HeaderAction headerAction) { var controlAction = new CMSButtonAction(); controlAction.Text = headerAction.Text; controlAction.Enabled = headerAction.Enabled && Enabled; controlAction.ToolTip = headerAction.Tooltip; // Register script only when action is active if (Enabled && headerAction.Enabled && !headerAction.Inactive) { // Wrap script from OnClick property into anonymous function so it won't cancel the following script in case this property scipt returns true. // The execution of following script is canceled only when anonymous function returns false. if (!String.IsNullOrEmpty(headerAction.OnClientClick)) { string onClickScript = "var onClickWrapper = function(sender) { " + headerAction.OnClientClick + "}; if (onClickWrapper(this) === false) { return false; }"; controlAction.OnClientClick = onClickScript; } string commandName = !string.IsNullOrEmpty(headerAction.CommandName) ? headerAction.CommandName : headerAction.EventName; // Perform post-back if (!String.IsNullOrEmpty(commandName) || !String.IsNullOrEmpty(headerAction.CommandArgument)) { string argument = string.Join(";", new[] { commandName, headerAction.CommandArgument }); var opt = new PostBackOptions(this, argument) { PerformValidation = true, ValidationGroup = headerAction.ValidationGroup }; string postbackScript = ControlsHelper.GetPostBackEventReference(this, opt, false, !PerformFullPostBack); controlAction.OnClientClick += postbackScript + ";"; } else { // Use URL only for standard link if (!String.IsNullOrEmpty(headerAction.RedirectUrl)) { var target = headerAction.Target ?? "_self"; var url = ScriptHelper.ResolveUrl(headerAction.RedirectUrl); if (headerAction.OpenInDialog) { url = URLHelper.AddParameterToUrl(url, "dialog", "1"); url = UIContextHelper.AppendDialogHash(url); ScriptHelper.RegisterDialogScript(Page); controlAction.OnClientClick = ScriptHelper.GetModalDialogScript(url, "action" + headerAction.Index, headerAction.DialogWidth, headerAction.DialogHeight, false); } else { controlAction.OnClientClick += "window.open('" + url + "','" + target + "');"; } } } // Stop automatic postback rendered by asp button controlAction.OnClientClick += " return false;"; } return controlAction; }
/// <summary> /// Retorna o JavaScript necessário para invocar o evento OnSelect /// </summary> /// <param name="idImagem">O ID da Imagem que será passado como parâmetro para o evento</param> /// <returns>O JavaScript</returns> protected string GetOnSelectEvent(object idImagem) { if (OnSelect != null && idImagem != null) { PostBackOptions options = new PostBackOptions(this); options.Argument = idImagem.ToString(); string postBackReference = Page.ClientScript.GetPostBackEventReference(options); return "checkOnlyOne(this,'idImagem');" + postBackReference + ";"; } return "checkOnlyOne(this,'idImagem');"; }
// Methods public void RegisterForEventValidation(PostBackOptions options) {}
public string GetPostBackEventReference(PostBackOptions options, bool registerForEventValidation) {}
private void CreateActions(List<HeaderAction> actions, Control parent, int level, bool useTable, bool renderAsContextMenu) { int actionsCount = actions.Count; if (useTable) { parent.Controls.Add(new LiteralControl("<table cellpadding=\"0\" cellspacing=\"0\" class=\"_nodivs\"><tr>")); } // Sort actions by index to be sure the order is ensured for multiple actions if (actionsCount > 1) { // At least one action has index if (ActionsList.Exists(a => (a.Index != -1))) { // Sort the actions ActionsList.Sort((a1, a2) => a1.Index.CompareTo(a2.Index)); } } // Generate the actions for (int i = 0; i < actionsCount; ++i) { var action = actions[i]; // If the text is not specified or visibility is false, skip the action FormSubmitButton formButton = action.BaseButton as FormSubmitButton; if (!action.IsVisible() || ((action.BaseButton != null) && (!action.BaseButton.Visible || ((formButton != null) && !formButton.RegisterHeaderAction)))) { // Skip empty action action.Visible = false; continue; } // Set live site flag for resource strings action.IsLiveSite = IsLiveSite; // Start tag of the table if more then one action is defined if (useTable) { if (action.GenerateSeparatorBeforeAction && (i > 0)) { parent.Controls.Add(new LiteralControl("<td class=\"PadSeparator\"><span></span></td>")); } parent.Controls.Add(new LiteralControl("<td>")); } // Context menu container ContextMenuContainer container = null; bool enabled = Enabled && action.Enabled; bool renderCtxMenu = (action.AlternativeActions.Count > 0); if (renderCtxMenu) { container = new ContextMenuContainer { ID = "menuCont" + i, MenuID = ClientID + "m_" + level + i, ParentElementClientID = ClientID, RenderAsTag = HtmlTextWriterTag.Div, MouseButton = MouseButtonEnum.Both, OffsetY = 1, VerticalPosition = VerticalPositionEnum.Bottom, HorizontalPosition = HorizontalPositionEnum.Left, CssClass = "CtxContainer", Enabled = enabled, IsLiveSite = IsLiveSite }; if (action.Inactive) { parent.Controls.Add(container); } } // Get the action parameters string ctrlId = ID + "_HA_" + level + i; string cssClass = !string.IsNullOrEmpty(action.CssClass) ? action.CssClass : LinkCssClass; string commandName = !string.IsNullOrEmpty(action.CommandName) ? action.CommandName : action.EventName; string url = ResolveUrl(action.RedirectUrl); // Add HyperLink HyperLink link = new HyperLink(); link.ID = ctrlId; link.ToolTip = action.Tooltip; link.CssClass = enabled ? cssClass : (cssClass + "Disabled"); link.Enabled = enabled; link.Text = action.Text; // Add control to the panel AddControlToPanel(link, (action.Inactive && (container != null)) ? container : parent, renderAsContextMenu); if (enabled && !action.Inactive) { // Perform post-back if (!String.IsNullOrEmpty(commandName)) { string script = null; // Register encapsulation function if (!string.IsNullOrEmpty(action.OnClientClick)) { link.Attributes.Add("onclick", action.OnClientClick); if (action.RegisterShortcutScript) { script = "if(!PerfAction_" + ctrlId + "()) { return false; }"; string scriptFunction = "function PerfAction_" + ctrlId + "() { " + action.OnClientClick.TrimEnd(';') + "; return true; }"; ScriptHelper.RegisterStartupScript(Page, typeof(string), "PerfAction_" + ctrlId, scriptFunction, true); } } string argument = string.Join(";", new string[] { commandName, action.CommandArgument }); PostBackOptions opt = new PostBackOptions(this, argument) { PerformValidation = true, ValidationGroup = action.ValidationGroup }; string postbackScript = ControlsHelper.GetPostBackEventReference(this, opt, false, !PerformFullPostBack); link.NavigateUrl = "javascript:" + postbackScript; // Register the CRTL+S shortcut if (action.RegisterShortcutScript) { // Store action information for shortcut event validation registration shortcutAction = new HeaderAction() { IsLiveSite = IsLiveSite, CommandArgument = argument, ValidationGroup = action.ValidationGroup }; // Prepare action script string actionScript = script + " " + postbackScript + ";"; // SaveObject function will simply simulate clicking the control string scriptSave = string.Format(@"function SaveObject() {{ {0} }}", actionScript); ScriptHelper.RegisterShortcuts(Page); ScriptHelper.RegisterStartupScript(Page, typeof(string), ScriptHelper.SAVE_DOCUMENT_SCRIPT_KEY, scriptSave, true); } } else { link.Attributes.Add("onclick", action.OnClientClick); // Use URL only for standard link if (!String.IsNullOrEmpty(action.RedirectUrl)) { link.NavigateUrl = url; link.Target = action.Target; } // Register the CRTL+S shortcut for empty command name if (action.RegisterShortcutScript) { // SaveObject function will simply simulate clicking the control string scriptSave = string.Format(@"function SaveObject() {{ {0} }}", action.OnClientClick); ScriptHelper.RegisterShortcuts(Page); ScriptHelper.RegisterStartupScript(Page, typeof(string), ScriptHelper.SAVE_DOCUMENT_SCRIPT_KEY, scriptSave, true); } } } // Create image if URL is not empty Image img = null; string imageUrl = (UseSmallIcons && !string.IsNullOrEmpty(action.SmallImageUrl)) ? action.SmallImageUrl : action.ImageUrl; if (!string.IsNullOrEmpty(imageUrl)) { if (action.UseImageButton) { ImageButton imgButton = new ImageButton(); if (!action.Inactive && enabled) { imgButton.PostBackUrl = url; } img = imgButton; } else { img = new Image(); } // Set common properties img.ID = ID + "_HAI_" + level + i; img.ImageUrl = imageUrl; img.ToolTip = action.Tooltip; img.AlternateText = action.Text; img.CssClass = IconCssClass; img.Enabled = enabled; } // Add controls to the panel if (img != null) { link.Controls.Add(img); } if (!string.IsNullOrEmpty(action.Text)) { link.Controls.Add(new Label { Text = action.Text, CssClass = "Text" }); } // Alternative actions if (renderCtxMenu) { if (!action.Inactive) { container.RenderAsTag = HtmlTextWriterTag.Span; container.OffsetX = -1; parent.Controls.Add(container); container.Controls.Add(new LiteralControl("<span class=\"SepContextButton\"><span class=\"Arrow\"></span></span>")); } else { link.Controls.Add(new LiteralControl("<span class=\"ContextButton\"><span class=\"Arrow\"></span></span>")); } // Context menu ContextMenu menu = new ContextMenu(); container.MenuControl = menu; container.InitializeMenuControl(menu); if (!String.IsNullOrEmpty(ContextMenuCssClass)) { menu.OuterCssClass = this.ContextMenuCssClass; } menu.CssClass = "PortalContextMenu CMSEditMenu"; CreateActions(action.AlternativeActions, menu, i, false, true); } // Do not insert padding for last item if (i < actionsCount - 1) { parent.Controls.Add(new LiteralControl("<span class=\"Pad\"></span>")); } // Add free separator cell in table if it's not the last action if (useTable) { parent.Controls.Add(new LiteralControl(((i < actionsCount - 1) && RenderSeparator ? "</td><td style=\"width:" + SeparatorWidth + "px; \" />" : "</td>"))); } } // End tag of the table if (useTable) { parent.Controls.Add(new LiteralControl("</tr></table>")); } }
/// <summary> /// Register the CRTL+S shortcut. /// </summary> /// <param name="action">Save header action</param> /// <param name="scriptID">Id of </param> private void RegisterSaveShortcutScript(HeaderAction action, string scriptID) { // Register script only when action is active if (Enabled && action.Enabled && !action.Inactive) { string commandName = !string.IsNullOrEmpty(action.CommandName) ? action.CommandName : action.EventName; string script = null; // Perform post-back if (!String.IsNullOrEmpty(commandName) || !String.IsNullOrEmpty(action.CommandArgument)) { // Register encapsulation function for OnClientClick in shortcut. if (!string.IsNullOrEmpty(action.OnClientClick)) { script = "if (PerfAction_" + scriptID + "() === false) { return false; }"; string scriptFunction = "function PerfAction_" + scriptID + "() { " + action.OnClientClick + "}"; ScriptHelper.RegisterStartupScript(Page, typeof(string), "PerfAction_" + scriptID, scriptFunction, true); } // Store action information for shortcut event validation registration shortcutAction = new HeaderAction { IsLiveSite = IsLiveSite, CommandArgument = action.CommandArgument, ValidationGroup = action.ValidationGroup }; string argument = string.Join(";", new[] { commandName, action.CommandArgument }); var opt = new PostBackOptions(this, argument) { PerformValidation = true, ValidationGroup = action.ValidationGroup }; string postbackScript = ControlsHelper.GetPostBackEventReference(this, opt, false, !PerformFullPostBack); // Prepare action script script = String.Concat(script, " ", postbackScript, ";"); } else { script = action.OnClientClick; } ScriptHelper.RegisterSaveShortcut(Page, script); } }
PostBackOptions GetPostBackOptions () { PostBackOptions options = new PostBackOptions (this); options.ValidationGroup = null; options.ActionUrl = null; options.Argument = String.Empty; options.RequiresJavaScriptProtocol = false; options.ClientSubmit = (0 != String.Compare (Type, "submit", true, Helpers.InvariantCulture)); options.PerformValidation = CausesValidation && Page != null && Page.Validators.Count > 0; if (options.PerformValidation) options.ValidationGroup = ValidationGroup; return options; }
PostBackOptions IPostBackContainer.GetPostBackOptions(IButtonControl buttonControl) { if (buttonControl == null) { throw new ArgumentNullException("buttonControl"); } if (buttonControl.CausesValidation) { throw new InvalidOperationException(SR.GetString(SR.CannotUseParentPostBackWhenValidating, this.GetType().Name, ID)); } PostBackOptions options = new PostBackOptions(this, (buttonControl.CommandName + "$" + buttonControl.CommandArgument)); options.RequiresJavaScriptProtocol = true; return options; }
PostBackOptions GetPostBackOptions () { Page page = Page; PostBackOptions options = new PostBackOptions (this); options.ValidationGroup = null; options.ActionUrl = null; options.Argument = String.Empty; options.RequiresJavaScriptProtocol = true; options.ClientSubmit = true; options.PerformValidation = CausesValidation && page != null && page.AreValidatorsUplevel (ValidationGroup); if (options.PerformValidation) options.ValidationGroup = ValidationGroup; return options; }
protected string GetPostBackScript() { PostBackOptions opts = new PostBackOptions(btnPostback); //Page.ClientScript.RegisterForEventValidation(options); //Return Page.ClientScript.GetPostBackEventReference(options); Page.ClientScript.RegisterForEventValidation(opts); return Page.ClientScript.GetPostBackEventReference(opts); }