public void ClientScriptManager_RegisterForEventValidationException() { Page p = new Page(); ClientScriptManager cs = p.ClientScript; cs.RegisterForEventValidation("ID", "args"); }
public static void AddDoubleClickAttributeToGridDataBound(ClientScriptManager manager, GridView grid, GridViewRowEventArgs e) { if (e.Row.RowType != DataControlRowType.DataRow) { return; } LinkButton dblClickButton = (LinkButton)e.Row.Cells[0].Controls[0]; string script = manager.GetPostBackClientHyperlink(dblClickButton, ""); e.Row.Attributes["ondblclick"] = script; manager.RegisterForEventValidation(e.Row.UniqueID + "$ctl00"); }
/// <summary> /// добавление двойного клика. считаем что кнонпка с двойным кликом идёт первой в списке колонок грида /// </summary> /// <param name="manager"></param> /// <param name="grid"></param> public static void AddDoubleClickAttributeToGrid(ClientScriptManager manager, GridView grid) { foreach (GridViewRow r in grid.Rows) { if (r.RowType == DataControlRowType.DataRow) { LinkButton dblClickButton = (LinkButton)r.Cells[0].Controls[0]; string script = manager.GetPostBackClientHyperlink(dblClickButton, ""); r.Attributes["ondblclick"] = script; manager.RegisterForEventValidation(r.UniqueID + "$ctl00"); } } }
protected internal override void RenderContents(HtmlTextWriter writer) { int idx = 0; Page page = Page; ClientScriptManager scriptManager = page != null ? page.ClientScript : null; foreach (ListItem i in Items) { if (page != null) { scriptManager.RegisterForEventValidation(UniqueID, i.Value); } if (i.HasAttributes) { i.Attributes.AddAttributes(writer); } writer.RenderBeginTag(HtmlTextWriterTag.Li); this.RenderBulletText(i, idx++, writer); writer.RenderEndTag(); } }
/// <summary> /// Registers an event reference for validation with <see cref="T:System.Web.UI.PostBackOptions"/>. /// </summary> /// <param name="options">A <see cref="T:System.Web.UI.PostBackOptions"/> object that specifies how client JavaScript is generated to initiate a postback event. /// </param> public void RegisterForEventValidation(PostBackOptions options) { _clientScriptManager.RegisterForEventValidation(options); }