Hello.

I draw a line from the table I clicked on in the textbox. I tried to do it, but the error comes out

"Invalid postback or callback argument. Event checking is enabled using <pages enableEventValidation =" true "/> in configuration or <% @ Page EnableEventValidation =" true "%> per page"

How to remove this error without using EnableEventValidation="true" , but through RegisterForEventValidation ?

Asp.net framework 2.0 c #

My code is:

 // Нажатие на кнопку вывода таблицы public void FindAdr_click(object sender, EventArgs e) { adres_data.SelectParameters.Remove(adres_data.SelectParameters["ul"]); adres_data.SelectParameters.Add("ul", adr_name.Text.ToString()); adres_data.SelectParameters["ul"].DefaultValue = adr_name.Text.ToString(); } //событие RowDataBound protected void adrTabl_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { if (e.Row.RowType == DataControlRowType.DataRow) { LinkButton _singleClickButton = (LinkButton)e.Row.Cells[0].Controls[0]; string _jsSingle = ClientScript.GetPostBackClientHyperlink(_singleClickButton, "Select$" + e.Row.RowIndex); e.Row.Style["cursor"] = "hand"; e.Row.Attributes["onclick"] = _jsSingle; e.Row.Attributes["onmouseover"] = "this.style.cursor='pointer';this.style.textDecoration='underline';"; e.Row.Attributes["onmouseout"] = "this.style.textDecoration='none';"; } } } // На выбор строки protected void adrTabl_SelectedIndexChanged(object sender, EventArgs e) { GridViewRow selectedRow = adrTabl.SelectedRow; adres.Text = selectedRow.Cells[1].Text + ",," + selectedRow.Cells[2].Text; adresF.Text = selectedRow.Cells[1].Text + ",," + selectedRow.Cells[2].Text; } 
  • it would be nice if your code was formatted - DreamChild
  • @DreamChild formatted - Andy92

1 answer 1

 protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { adres_data.SelectParameters.Add("ul", adr_name.Text.ToString()); ds_mkb.SelectParameters.Add("nameds", "%" + mkb_name.Text.ToString() + "%"); ds_katl.SelectParameters.Add("nemka", katnamed.Text.ToString()); } } 

Render:

 protected override void Render(HtmlTextWriter writer) { foreach (GridViewRow r in adrTabl.Rows) { if (r.RowType == DataControlRowType.DataRow) { LinkButton _singleClickButton = (LinkButton)r.Cells[0].Controls[0]; string _jsSingle = ClientScript.GetPostBackClientHyperlink(_singleClickButton, "Select$" + r.RowIndex); r.Style["cursor"] = "hand"; r.Attributes["onclick"] = _jsSingle; r.Attributes["onmouseover"] = "this.style.cursor='pointer';this.style.textDecoration='underline';"; r.Attributes["onmouseout"] = "this.style.textDecoration='none';"; ClientScript.RegisterForEventValidation(((LinkButton)r.Cells[0].Controls[0]).UniqueID, "Select$" + r.RowIndex); } base.Render(writer); } }