/// <summary> /// Adds an onclick attribute for post back refresh navigation when javascript is on /// </summary> /// <param name="writer">The output stream to render on the client</param> protected override void BeginRender(HtmlTextWriter writer) { if (HyperLink.Enabled && HyperLink.Attributes["__ToData"] != null) { PostBackOptions postBackOptions = new PostBackOptions(HyperLink); postBackOptions.Argument = REFRESH_POST_BACK; writer.AddAttribute(HtmlTextWriterAttribute.Onclick, string.Format(CultureInfo.InvariantCulture, "if(!event.ctrlKey&&!event.shiftKey){{{0};return false;}}", Page.ClientScript.GetPostBackEventReference(postBackOptions, true))); } HyperLink.Attributes.Remove("__ToData"); base.BeginRender(writer); }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { //string qsuimode = Request.QueryString["mode"]; //if (string.IsNullOrEmpty(qsuimode) == false) //{ // _mode = (UIMode.mode)Enum.Parse(typeof(UIMode.mode), qsuimode); // if (_mode == UIMode.mode.add) // { loadPermissionToChkBoxListPermission(); ShowMenuSections(); // } // if (_mode == UIMode.mode.edit) // { // _idx = Convert.ToInt32(Request.QueryString["idx"]); // LoadData(); // hdnWindowUIMODE.Value = _mode.ToString(); // } TreeView1.Attributes.Add("onclick", "OnCheckBoxCheckChanged(event)"); //} 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 Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { string qsuimode = Request.QueryString["mode"]; if (string.IsNullOrEmpty(qsuimode) == false) { _mode = (UIMode.mode)Enum.Parse(typeof(UIMode.mode), qsuimode); if (_mode == UIMode.mode.add) { LoadApplicationList2DDL(); PopulatePortalList2DDL(); LoadSkinTypeList2DDL(); LoadPackageList2DDL(); } if (_mode == UIMode.mode.edit) { _idx = Convert.ToInt32(Request.QueryString["idx"]); LoadData(); } hdnWindowUIMODE.Value = _mode.ToString(); } MultiView1.ActiveViewIndex = 0; } 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) { string qsuimode = Request.QueryString["mode"]; if (string.IsNullOrEmpty(qsuimode) == false) { _mode = (UIMode.mode)Enum.Parse(typeof(UIMode.mode), qsuimode); if (_mode == UIMode.mode.edit) { _idx =Convert.ToInt32(Request.QueryString["idx"]); LoadData(); hdnWindowUIMODE.Value = _mode.ToString(); } } 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 override void Render(HtmlTextWriter writer) { Button button = this.Control; writer.WriteBeginTag("button"); // <button writer.WriteAttribute("value", "submit"); // <button value="submit" writer.WriteAttribute("id", button.ClientID); // <button value="submit" id="btnButton" PostBackOptions myPostBackOptions = new PostBackOptions(button); //Add the Postback event if (button.Page.ClientScript.GetPostBackEventReference(myPostBackOptions).Length > 0) { //Turn on Validation if it needs to be on... if (button.CausesValidation) myPostBackOptions.PerformValidation = true; //Need to replace double quotes with single quotes for javascript to work. writer.WriteAttribute("onclick", button.Page.ClientScript.GetPostBackEventReference(myPostBackOptions).Replace("\"", "'")); // <button value="submit" //Register the Event button.Page.ClientScript.RegisterForEventValidation(myPostBackOptions); } // <button value="submit" id="btnButton" onclick="__doPostBack('btnButton','')" if (button.CssClass.Length > 0) writer.WriteAttribute("class", button.CssClass); // <button value="submit" id="btnButton" onclick="__doPostBack('btnButton','')" class="large-button" writer.Write(HtmlTextWriter.TagRightChar); // <button value="submit" id="btnButton" onclick="__doPostBack('btnButton','')" class="large-button"> writer.WriteFullBeginTag("span"); writer.Write(button.Text); writer.WriteEndTag("span"); // <button value="submit" id="btnButton" onclick="__doPostBack('btnButton','')" class="large-button"><span>testButton</span> writer.WriteEndTag("button"); // <button value="submit" id="btnButton" onclick="__doPostBack('btnButton','')" class="large-button"><span>testButton</span></button> }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { string qsuimode = Request.QueryString["mode"]; if (string.IsNullOrEmpty(qsuimode) == false) { _mode = (UIMode.mode)Enum.Parse(typeof(UIMode.mode), qsuimode); if (_mode == UIMode.mode.add) { ShowTreeNodes_Topics(); CollectionList2DDL(); } if (_mode == UIMode.mode.edit) { _idx = Convert.ToInt32(Request.QueryString["idx"]); LoadData(); } hdnWindowUIMODE.Value = _mode.ToString(); } Session["update"] = Server.UrlEncode(System.DateTime.Now.ToString()); MultiView1.ActiveViewIndex = 0; } 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) { string qsuimode = Request.QueryString["mode"]; if (string.IsNullOrEmpty(qsuimode) == false) { _idx = Convert.ToInt32(Request.QueryString["idx"]); LoadData(); } Session["FileUpload1"] = null; MultiView1.ActiveViewIndex = 0; } else { if (FileUpload1.HasFile) { Session["FileUpload1"] = FileUpload1; } else if (Session["FileUpload1"] != null) { FileUpload1 = (FileUpload)Session["FileUpload1"]; } } PostBackOptions optionsSubmit = new PostBackOptions(btnOkay); btnOkay.OnClientClick = "disableButtonOnClick(this, 'Please wait...', 'disabled_button'); "; btnOkay.OnClientClick += ClientScript.GetPostBackEventReference(optionsSubmit); }
public string GetPostBackEventReference (PostBackOptions options) { if (options.ActionUrl == null && options.ValidationGroup == null && !options.TrackFocus && !options.AutoPostBack && !options.PerformValidation) { if (options.RequiresJavaScriptProtocol) return GetPostBackClientHyperlink (options.TargetControl, options.Argument); else return GetPostBackEventReference (options.TargetControl, options.Argument); } if (!IsClientScriptIncludeRegistered (typeof(Page), "webform")) { RegisterClientScriptInclude (typeof(Page), "webform", GetWebResourceUrl (typeof(Page), "webform.js")); } if (options.ActionUrl != null) RegisterHiddenField (Page.PreviousPageID, page.Request.FilePath); if (options.ClientSubmit || options.ActionUrl != null) page.RequiresPostBackScript (); return String.Format ("{0}WebForm_DoPostback({1},{2},{3},{4},{5},{6},{7},{8})", options.RequiresJavaScriptProtocol ? "javascript:" : "", ClientScriptManager.GetScriptLiteral (options.TargetControl.UniqueID), ClientScriptManager.GetScriptLiteral (options.Argument), ClientScriptManager.GetScriptLiteral (options.ActionUrl), ClientScriptManager.GetScriptLiteral (options.AutoPostBack), ClientScriptManager.GetScriptLiteral (options.PerformValidation), ClientScriptManager.GetScriptLiteral (options.TrackFocus), ClientScriptManager.GetScriptLiteral (options.ClientSubmit), ClientScriptManager.GetScriptLiteral (options.ValidationGroup) ); }
protected void GridViewInsertRowSelectScript(object sender, GridViewRowEventArgs e) { if (isRowSelectable && e.Row.RowType == DataControlRowType.DataRow && ((e.Row.RowState & DataControlRowState.Edit) != DataControlRowState.Edit)) { var postOptions = new PostBackOptions(gridView, "Select$" + e.Row.RowIndex); String selectScript = gridView.Page.ClientScript.GetPostBackEventReference(postOptions); // // This for not uses equal, to not overbound the index // //for (int a = 0; a < e.Row.Cells.Count-1; a++) //{ // if (gridView.Columns[a].SortExpression != "Insert") // e.Row.Cells[a].Attributes.Add("onclick", selectScript); //} e.Row.Attributes.Add("onclick", selectScript); //foreach (TableCell cell in e.Row.Cells) //{ // int i = e.Row.Cells.GetCellIndex(cell); // if (gridView.Columns[i].GetType().Name != "CommandField") // if (e.Row.RowType == DataControlRowType.DataRow) // e.Row.Cells[a].Attributes.Add("onclick", selectScript); //} } }
internal override void RenderInputTag(HtmlTextWriter writer, string clientID, string onClick) { writer.AddAttribute(HtmlTextWriterAttribute.Id, clientID); writer.AddAttribute(HtmlTextWriterAttribute.Type, "radio"); writer.AddAttribute(HtmlTextWriterAttribute.Name, this.UniqueGroupName); writer.AddAttribute(HtmlTextWriterAttribute.Value, this.ValueAttribute); if (this.Page != null) { this.Page.ClientScript.RegisterForEventValidation(this.UniqueGroupName, this.ValueAttribute); } if (this.Checked) { writer.AddAttribute(HtmlTextWriterAttribute.Checked, "checked"); } if (!base.IsEnabled && this.SupportsDisabledAttribute) { writer.AddAttribute(HtmlTextWriterAttribute.Disabled, "disabled"); } if ((this.AutoPostBack && !this.Checked) && (this.Page != null)) { 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; } onClick = Util.MergeScript(onClick, this.Page.ClientScript.GetPostBackEventReference(options)); writer.AddAttribute(HtmlTextWriterAttribute.Onclick, onClick); if (base.EnableLegacyRendering) { writer.AddAttribute("language", "javascript", false); } } else if (onClick != null) { writer.AddAttribute(HtmlTextWriterAttribute.Onclick, onClick); } string accessKey = this.AccessKey; if (accessKey.Length > 0) { writer.AddAttribute(HtmlTextWriterAttribute.Accesskey, accessKey); } int tabIndex = this.TabIndex; if (tabIndex != 0) { writer.AddAttribute(HtmlTextWriterAttribute.Tabindex, tabIndex.ToString(NumberFormatInfo.InvariantInfo)); } if ((base._inputAttributes != null) && (base._inputAttributes.Count != 0)) { base._inputAttributes.AddAttributes(writer); } writer.RenderBeginTag(HtmlTextWriterTag.Input); writer.RenderEndTag(); }
protected override void RenderContents(HtmlTextWriter output) { PostBackOptions p = new PostBackOptions(this); output.AddAttribute(HtmlTextWriterAttribute.Id, this.ClientID); output.AddAttribute(HtmlTextWriterAttribute.Name, this.ClientID); output.AddAttribute(HtmlTextWriterAttribute.Value, this.Text); output.RenderBeginTag(HtmlTextWriterTag.Input); output.RenderEndTag(); }
/// <summary> /// Overridden Render method solely to do registration for event validation /// </summary> /// <param name="writer">HtmlTextWriter object</param> protected override void Render(HtmlTextWriter writer) { PostBackOptions options = new PostBackOptions(this.btnDummyToPostBack); if (options != null) { options.PerformValidation = true; Page.ClientScript.RegisterForEventValidation(options); this.litPostBack.Text = String.Format("{0}{1}{2}", "<script type=\"text/javascript\" language=\"javascript\">function doPostBack() { ", Page.ClientScript.GetPostBackEventReference(options), "}</script>"); ; } base.Render(writer); }
public void Constructors () { Control c = new WebControl(HtmlTextWriterTag.A); c.Page = new Page (); PostBackOptions options=new PostBackOptions(c); Assert.IsFalse (options.PerformValidation); Assert.IsFalse (options.AutoPostBack); Assert.IsFalse (options.TrackFocus); Assert.IsTrue (options.ClientSubmit); // MSDN: The default value is true, BUT FALSE Assert.IsFalse (options.RequiresJavaScriptProtocol); // MSDN: The default value is an empty string (""), BUT NULL Assert.AreEqual (null, options.Argument); // MSDN: The default value is an empty string (""), BUT NULL Assert.AreEqual (null, options.ActionUrl); // MSDN: The default value is an empty string (""), BUT NULL Assert.AreEqual (null, options.ValidationGroup); options = new PostBackOptions (c, null); Assert.IsFalse (options.PerformValidation); Assert.IsFalse (options.AutoPostBack); Assert.IsFalse (options.TrackFocus); Assert.IsTrue (options.ClientSubmit); Assert.IsFalse (options.RequiresJavaScriptProtocol); Assert.AreEqual (null, options.Argument); Assert.AreEqual (null, options.ActionUrl); Assert.AreEqual (null, options.ValidationGroup); options = new PostBackOptions (c, null, null, false, false, false, false, false, null); Assert.IsFalse (options.PerformValidation); Assert.IsFalse (options.AutoPostBack); Assert.IsFalse (options.TrackFocus); Assert.IsFalse (options.ClientSubmit); Assert.IsFalse (options.RequiresJavaScriptProtocol); Assert.AreEqual (null, options.Argument); Assert.AreEqual (null, options.ActionUrl); Assert.AreEqual (null, options.ValidationGroup); options = new PostBackOptions (c, "ARG"); Assert.IsFalse (options.PerformValidation); Assert.IsFalse (options.AutoPostBack); Assert.IsFalse (options.TrackFocus); Assert.IsTrue (options.ClientSubmit); Assert.IsFalse (options.RequiresJavaScriptProtocol); Assert.AreEqual ("ARG", options.Argument); Assert.AreEqual (null, options.ActionUrl); Assert.AreEqual (null, options.ValidationGroup); options = new PostBackOptions (c, "ARG", "Page.aspx", true, true, false, false, false, "VG"); Assert.IsFalse (options.PerformValidation); Assert.IsTrue (options.AutoPostBack); Assert.IsFalse (options.TrackFocus); Assert.IsFalse (options.ClientSubmit); Assert.IsTrue (options.RequiresJavaScriptProtocol); Assert.AreEqual ("ARG", options.Argument); Assert.AreEqual ("Page.aspx", options.ActionUrl); Assert.AreEqual ("VG", options.ValidationGroup); }
private PostBackOptions GetPostBackOptions() { PostBackOptions options = new PostBackOptions(this, string.Empty) { RequiresJavaScriptProtocol = true }; if (this.CausesValidation && (this.Page.GetValidators(this.ValidationGroup).Count > 0)) { options.PerformValidation = true; options.ValidationGroup = this.ValidationGroup; } return options; }
protected override void RenderContents(HtmlTextWriter output) { PostBackOptions p = new PostBackOptions(this); output.AddAttribute(HtmlTextWriterAttribute.Onclick, Page.ClientScript.GetPostBackEventReference(p)); output.AddAttribute(HtmlTextWriterAttribute.Value, "My Button"); output.AddAttribute(HtmlTextWriterAttribute.Id, this.ClientID + "_i"); output.AddAttribute(HtmlTextWriterAttribute.Name, this.ClientID + "_i"); output.RenderBeginTag(HtmlTextWriterTag.Button); output.RenderEndTag(); }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { LoadData(); FillDataInGrid(); MultiView1.ActiveViewIndex = 0; } 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 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) { PopulateApplicationList2DDL(); PopulateLanguage2DDL(); 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 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); }
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 void grdDependents_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow && e.Row.RowState != DataControlRowState.Edit) { if (e.Row.RowState == DataControlRowState.Alternate || e.Row.RowState == DataControlRowState.Normal) { PostBackOptions postOptions = new PostBackOptions(grdDependents, "Edit$" + 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 Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { _idx =Convert.ToInt32(Request.QueryString["idx"]); LoadData(); txtHostFee.Attributes["onkeyup"] = "javascript: FormatNumber(this);return false;"; txtHostFee.Attributes.Add("value", txtHostFee.Text); txtHostFee.Attributes.Add("style", "text-align:right"); txtHostSpace.Attributes.Add("style", "text-align:right"); MultiView1.ActiveViewIndex = 0; } 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) { string qsuimode = Request.QueryString["mode"]; if (string.IsNullOrEmpty(qsuimode) == false) { _mode = (UIMode.mode)Enum.Parse(typeof(UIMode.mode), qsuimode); if (_mode == UIMode.mode.add) { ShowTreeNodes(); } hdnWindowUIMODE.Value = _mode.ToString(); } MultiView1.ActiveViewIndex = 0; } PostBackOptions optionsSubmit = new PostBackOptions(btnOkay); btnOkay.OnClientClick = "disableButtonOnClick(this, 'Please wait...', 'disabled_button'); "; btnOkay.OnClientClick += ClientScript.GetPostBackEventReference(optionsSubmit); }
PostBackOptions IPostBackContainer.GetPostBackOptions (IButtonControl control) { if (control == null) throw new ArgumentNullException ("control"); if (control.CausesValidation) throw new InvalidOperationException ("A button that causes validation in GridView '" + ID + "' is attempting to use the container GridView as the post back target. The button should either turn off validation or use itself as the post back container."); PostBackOptions options = new PostBackOptions (this); options.Argument = control.CommandName + "$" + control.CommandArgument; options.RequiresJavaScriptProtocol = true; return options; }
string IClientScriptManager.GetPostBackEventReference(PostBackOptions options) { return(_clientScriptManager.GetPostBackEventReference(options)); }
public string GetPostBackEventReference(PostBackOptions options) { return(default(string)); }
public string GetPostBackEventReference(PostBackOptions options, bool registerForEventValidation) { return(default(string)); }
internal virtual void RenderInputTag(HtmlTextWriter writer, string clientID, string onClick) { if (clientID != null) { writer.AddAttribute(HtmlTextWriterAttribute.Id, clientID); } writer.AddAttribute(HtmlTextWriterAttribute.Type, "checkbox"); if (UniqueID != null) { writer.AddAttribute(HtmlTextWriterAttribute.Name, UniqueID); } // Whidbey 20815 if (_valueAttribute != null) { writer.AddAttribute(HtmlTextWriterAttribute.Value, _valueAttribute); } if (Checked) writer.AddAttribute(HtmlTextWriterAttribute.Checked, "checked"); // ASURT 119141: Render ---- attribute on the INPUT tag (instead of the SPAN) so the checkbox actually gets disabled when Enabled=false if (!IsEnabled && SupportsDisabledAttribute) { writer.AddAttribute(HtmlTextWriterAttribute.Disabled, "disabled"); } if (AutoPostBack && (Page != null) && Page.ClientSupportsJavaScript) { PostBackOptions options = new PostBackOptions(this, String.Empty); if (CausesValidation && Page.GetValidators(ValidationGroup).Count > 0) { options.PerformValidation = true; options.ValidationGroup = ValidationGroup; } if (Page.Form != null) { options.AutoPostBack = true; } // ASURT 98368 // Need to merge the autopostback script with the user script onClick = Util.MergeScript(onClick, Page.ClientScript.GetPostBackEventReference(options, true)); writer.AddAttribute(HtmlTextWriterAttribute.Onclick, onClick); if (EnableLegacyRendering) { writer.AddAttribute("language", "javascript", false); } } else { if (Page != null) { Page.ClientScript.RegisterForEventValidation(this.UniqueID); } if (onClick != null) { writer.AddAttribute(HtmlTextWriterAttribute.Onclick, onClick); } } string s = AccessKey; if (s.Length > 0) writer.AddAttribute(HtmlTextWriterAttribute.Accesskey, s); int i = TabIndex; if (i != 0) writer.AddAttribute(HtmlTextWriterAttribute.Tabindex, i.ToString(NumberFormatInfo.InvariantInfo)); if (_inputAttributes != null && _inputAttributes.Count != 0) { _inputAttributes.AddAttributes(writer); } writer.RenderBeginTag(HtmlTextWriterTag.Input); writer.RenderEndTag(); }
public void RegisterForEventValidation(PostBackOptions options) { Contract.Requires(options != null); }
public void RegisterForEventValidation(PostBackOptions options) { // MS.NET does not check for options == null, so we won't too... RegisterForEventValidation(options.TargetControl.UniqueID, options.Argument); }
private void WriteCreateUserButtonPanel(HtmlTextWriter writer, CreateUserWizard wizard) { Control btnParentCtrl = wizard.FindControl("__CustomNav0"); if (btnParentCtrl != null) { string id = "_CustomNav0_StepNextButton"; string idWithType = WebControlAdapterExtender.MakeIdWithButtonType("StepNextButton", wizard.CreateUserButtonType); Control btn = btnParentCtrl.FindControl(idWithType); if (btn != null) { Page.ClientScript.RegisterForEventValidation(btn.UniqueID); PostBackOptions options = new PostBackOptions(btn, "", "", false, false, false, false, true, wizard.ID); string javascript = "javascript:" + Page.ClientScript.GetPostBackEventReference(options); javascript = Page.Server.HtmlEncode(javascript); WebControlAdapterExtender.WriteBeginDiv(writer, "AspNet-CreateUserWizard-CreateUserButtonPanel"); Extender.WriteSubmit(writer, wizard.CreateUserButtonType, wizard.CreateUserButtonStyle.CssClass, id, wizard.CreateUserButtonImageUrl, javascript, wizard.CreateUserButtonText); if (wizard.DisplayCancelButton) { Extender.WriteSubmit(writer, wizard.CancelButtonType, wizard.CancelButtonStyle.CssClass, "_CustomNav0_CancelButton", wizard.CancelButtonImageUrl, "", wizard.CancelButtonText); } WebControlAdapterExtender.WriteEndDiv(writer); } } }
public string GetPostBackEventReference(PostBackOptions options) { return(this.GetPostBackEventReference(options, false)); }
protected virtual PostBackOptions GetPostBackOptions () { PostBackOptions ops = new PostBackOptions (this); if (PostBackUrl != "") ops.ActionUrl = PostBackUrl; ops.PerformValidation = Page.Validators.Count > 0 && CausesValidation; if (ops.PerformValidation && ValidationGroup != "") ops.ValidationGroup = ValidationGroup; ops.RequiresJavaScriptProtocol = false; return ops; }
protected override void OnInit(EventArgs e) { PostBackOptions p = new PostBackOptions(this); Panel lPanel = new Panel(); lPanel.CssClass = "RibbonGalleryItem"; lPanel.Attributes.Add("onclick", this._clientClick + "; " + Page.ClientScript.GetPostBackEventReference(p)); this.Controls.Add(lPanel); if (!String.IsNullOrEmpty(this._tooltip)) { lPanel.CssClass += " RibbonItemWithTooltip"; lPanel.Attributes.Add("tooltip", this._tooltip); } Table lTable = new Table(); lTable.Style.Add("margin-left", "auto"); lTable.Style.Add("margin-right", "auto"); lTable.CellSpacing = 0; lTable.CellPadding = 0; lPanel.Controls.Add(lTable); TableRow lTableRowImage = new TableRow(); lTable.Controls.Add(lTableRowImage); TableCell lTableCellImage = new TableCell(); lTableCellImage.HorizontalAlign = HorizontalAlign.Center; lTableRowImage.Controls.Add(lTableCellImage); Image lImage = new Image(); lImage.ImageUrl = this._imageUrl; lTableCellImage.Controls.Add(lImage); TableRow lTableRowText = new TableRow(); lTableRowText.HorizontalAlign = HorizontalAlign.Center; lTable.Controls.Add(lTableRowText); TableCell lTableCellText = new TableCell(); lTableRowText.Controls.Add(lTableCellText); Literal lText = new Literal(); lText.Text = this._text; lTableCellText.Controls.Add(lText); base.OnInit(e); }
public string GetPostBackEventReference(PostBackOptions options, bool registerForEventValidation) { if (options == null) { throw new ArgumentNullException("options"); } if (registerForEventValidation) { this.RegisterForEventValidation(options); } StringBuilder builder = new StringBuilder(); bool flag = false; if (options.RequiresJavaScriptProtocol) { builder.Append("javascript:"); } if (options.AutoPostBack) { builder.Append("setTimeout('"); } if ((!options.PerformValidation && !options.TrackFocus) && (options.ClientSubmit && string.IsNullOrEmpty(options.ActionUrl))) { string postBackEventReference = this.GetPostBackEventReference(options.TargetControl, options.Argument); if (options.AutoPostBack) { builder.Append(Util.QuoteJScriptString(postBackEventReference)); builder.Append("', 0)"); } else { builder.Append(postBackEventReference); } return(builder.ToString()); } builder.Append("WebForm_DoPostBackWithOptions"); builder.Append("(new WebForm_PostBackOptions(\""); builder.Append(options.TargetControl.UniqueID); builder.Append("\", "); if (string.IsNullOrEmpty(options.Argument)) { builder.Append("\"\", "); } else { builder.Append("\""); builder.Append(Util.QuoteJScriptString(options.Argument)); builder.Append("\", "); } if (options.PerformValidation) { flag = true; builder.Append("true, "); } else { builder.Append("false, "); } if ((options.ValidationGroup != null) && (options.ValidationGroup.Length > 0)) { flag = true; builder.Append("\""); builder.Append(options.ValidationGroup); builder.Append("\", "); } else { builder.Append("\"\", "); } if ((options.ActionUrl != null) && (options.ActionUrl.Length > 0)) { flag = true; this._owner.ContainsCrossPagePost = true; builder.Append("\""); builder.Append(Util.QuoteJScriptString(options.ActionUrl)); builder.Append("\", "); } else { builder.Append("\"\", "); } if (options.TrackFocus) { this._owner.RegisterFocusScript(); flag = true; builder.Append("true, "); } else { builder.Append("false, "); } if (options.ClientSubmit) { flag = true; this._owner.RegisterPostBackScript(); builder.Append("true))"); } else { builder.Append("false))"); } if (options.AutoPostBack) { builder.Append("', 0)"); } string str2 = null; if (flag) { str2 = builder.ToString(); this._owner.RegisterWebFormsScript(); } return(str2); }
public void RegisterForEventValidation(PostBackOptions options) { }
// Returns the client post back options. protected virtual PostBackOptions GetPostBackOptions() { PostBackOptions options = new PostBackOptions(this, String.Empty); options.RequiresJavaScriptProtocol = false; if (!String.IsNullOrEmpty(PostBackUrl)) { // VSWhidbey 424614: Since the url is embedded as javascript in attribute, // we should match the same encoding as done on HyperLink.NavigateUrl value. options.ActionUrl = HttpUtility.UrlPathEncode(ResolveClientUrl(PostBackUrl)); // Also, there is a specific behavior in IE that when the script // is triggered in href attribute, the whole string will be // decoded once before the code is run. This doesn't happen to // onclick or other event attributes. So here we do an extra // encoding to compensate the weird behavior on IE. if (!DesignMode && Page != null && String.Equals(Page.Request.Browser.Browser, "IE", StringComparison.OrdinalIgnoreCase)) { options.ActionUrl = Util.QuoteJScriptString(options.ActionUrl, true); } } if (CausesValidation && Page.GetValidators(ValidationGroup).Count > 0) { options.PerformValidation = true; options.ValidationGroup = ValidationGroup; } return options; }
public void RegisterForEventValidation(PostBackOptions options) { this.RegisterForEventValidation(options.TargetControl.UniqueID, options.Argument); }