Hi all,
This is my first message here so i'll try and include all the
information that will help you help me out, if possible.
Basically I am using C# in ASP.NET 2.0 and have a Repeater control in
my aspx page with two image buttons, one for an edit command, another a
delete command. Here is a cut down code fragment.
---------------------------------------------------------------------------------------------------------------------------
<asp:Repeater ID="rptData" runat="server">
<ItemTemplate>
<div class="row">
<p class="dataPara">
<span style="float: right; padding-left: 5px;">
<asp:ImageButton ID="imgbDelete" runat="server"
ImageUrl="img/delete.gif" AlternateText="Delete" CommandName="Delete"
/>
</span>
<span style="float: right; padding-left: 5px;">
<asp:ImageButton ID="imgbEdit" runat="server"
ImageUrl="img/edit.gif" AlternateText="Edit" CommandName="Edit" />
</span>
<%# DataBinder.Eval(Container.DataItem, "Item") %>
</p>
</div>
</ItemTemplate>
</asp:Repeater>
---------------------------------------------------------------------------------------------------------------------------
Basically what happens is that i get a set of rows with delete and edit
buttons for each record in my dataset, which is as expected, however as
soon as you click one of these buttons i recieve the following error.
In case you wondered why i'm not using a DataGrid, the reason is
because the HTML for the item template is alot more complex, this is
simply cut down to illustrate my problem i'm getting.
---------------------------------------------------------------------------------------------------------------------------
Invalid postback or callback argument. Event validation is enabled
using <pages enableEventValidation="true"/> in configuration or <%@
Page EnableEventValidation="true" %> in a page. For security purposes,
this feature verifies that arguments to postback or callback events
originate from the server control that originally rendered them. If
the data is valid and expected, use the
ClientScriptManager.RegisterForEventValidation method in order to
register the postback or callback data for validation.
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.
Exception Details: System.ArgumentException: Invalid postback or
callback argument. Event validation is enabled using <pages
enableEventValidation="true"/> in configuration or <%@ Page
EnableEventValidation="true" %> in a page. For security purposes, this
feature verifies that arguments to postback or callback events
originate from the server control that originally rendered them. If
the data is valid and expected, use the
ClientScriptManager.RegisterForEventValidation method in order to
register the postback or callback data for validation.
Source Error:
An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of
the exception can be identified using the exception stack trace below.
Stack Trace:
[ArgumentException: Invalid postback or callback argument. Event
validation is enabled using <pages enableEventValidation="true"/> in
configuration or <%@ Page EnableEventValidation="true" %> in a page.
For security purposes, this feature verifies that arguments to postback
or callback events originate from the server control that originally
rendered them. If the data is valid and expected, use the
ClientScriptManager.RegisterForEventValidation method in order to
register the postback or callback data for validation.]
System.Web.UI.ClientScriptManager.ValidateEvent(St ring uniqueId,
String argument) +2080220
System.Web.UI.Control.ValidateEvent(String uniqueID, String
eventArgument) +106
System.Web.UI.WebControls.ImageButton.RaisePostBac kEvent(String
eventArgument) +32
System.Web.UI.WebControls.ImageButton.System.Web.U I.IPostBackEventHandler.RaisePostBackEvent(String
eventArgument) +7
System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler
sourceControl, String eventArgument) +11
System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData)
+33
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
+5102
---------------------------------------------------------------------------------------------------------------------------
Obviously setting the pages requireseventvalidation="false" in
web.config removes this error, but i would rather find a work around to
this. After searching the web my first attempts at doing this have been
unsuccessful, and i'm now at a dead end. So far i have tried the
following code in my code behind.
---------------------------------------------------------------------------------------------------------------------------
protected override void Render(HtmlTextWriter writer)
{
for (int i = 0; i < tblData.Rows.Count; i++)
{
Page.ClientScript.RegisterForEventValidation("rptD ata$ctl"
+ String.Format("{0:00}", i) + "$imgbEdit");
Page.ClientScript.RegisterForEventValidation("rptD ata$ctl"
+ String.Format("{0:00}", i) + "$imgbDelete");
RegisterRequiresPostBack(rptData.Items[i].Controls[1]);
RegisterRequiresPostBack(rptData.Items[i].Controls[3]);
}
base.Render(writer);
}
---------------------------------------------------------------------------------------------------------------------------
I obtained the unique ID's for the controls by iterating through the
controls in each row of the repeater to find them and then used the
following code above to try and register them. However this does not
seem to solve the problem so i think i'm not obtaining the right ID's
for the controls or i'm missing something else or not understanding the
requirements of the function. In case anyone is wondering the
RegisterRequiresPostBack() function was added after i read a suggestion
to add it from another thread referencing the same exception, but this
does not seem to solve the problem either.
Any help would be greatful, otherwise i'll have to resort to turning
off event validation which ideally i don't want to do.
Kind Regards,
Tim Anderson 1 17009
most likely you are not recreating the repeater the same on the postback, so
the control ids on the postback page don't match the original rendered page.
-- bruce (sqlwork.com)
"Timbo" <ti**************@btconnect.com> wrote in message
news:11*********************@j73g2000cwa.googlegro ups.com... Hi all,
This is my first message here so i'll try and include all the information that will help you help me out, if possible.
Basically I am using C# in ASP.NET 2.0 and have a Repeater control in my aspx page with two image buttons, one for an edit command, another a delete command. Here is a cut down code fragment.
---------------------------------------------------------------------------------------------------------------------------
<asp:Repeater ID="rptData" runat="server"> <ItemTemplate> <div class="row"> <p class="dataPara"> <span style="float: right; padding-left: 5px;"> <asp:ImageButton ID="imgbDelete" runat="server" ImageUrl="img/delete.gif" AlternateText="Delete" CommandName="Delete" /> </span> <span style="float: right; padding-left: 5px;"> <asp:ImageButton ID="imgbEdit" runat="server" ImageUrl="img/edit.gif" AlternateText="Edit" CommandName="Edit" /> </span> <%# DataBinder.Eval(Container.DataItem, "Item") %> </p> </div> </ItemTemplate> </asp:Repeater>
---------------------------------------------------------------------------------------------------------------------------
Basically what happens is that i get a set of rows with delete and edit buttons for each record in my dataset, which is as expected, however as soon as you click one of these buttons i recieve the following error.
In case you wondered why i'm not using a DataGrid, the reason is because the HTML for the item template is alot more complex, this is simply cut down to illustrate my problem i'm getting.
---------------------------------------------------------------------------------------------------------------------------
Invalid postback or callback argument. Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@ Page EnableEventValidation="true" %> in a page. For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them. If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentException: Invalid postback or callback argument. Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@ Page EnableEventValidation="true" %> in a page. For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them. If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[ArgumentException: Invalid postback or callback argument. Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@ Page EnableEventValidation="true" %> in a page. For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them. If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.] System.Web.UI.ClientScriptManager.ValidateEvent(St ring uniqueId, String argument) +2080220 System.Web.UI.Control.ValidateEvent(String uniqueID, String eventArgument) +106 System.Web.UI.WebControls.ImageButton.RaisePostBac kEvent(String eventArgument) +32
System.Web.UI.WebControls.ImageButton.System.Web.U I.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7 System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler sourceControl, String eventArgument) +11 System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData) +33 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5102
---------------------------------------------------------------------------------------------------------------------------
Obviously setting the pages requireseventvalidation="false" in web.config removes this error, but i would rather find a work around to this. After searching the web my first attempts at doing this have been unsuccessful, and i'm now at a dead end. So far i have tried the following code in my code behind.
---------------------------------------------------------------------------------------------------------------------------
protected override void Render(HtmlTextWriter writer) { for (int i = 0; i < tblData.Rows.Count; i++) { Page.ClientScript.RegisterForEventValidation("rptD ata$ctl" + String.Format("{0:00}", i) + "$imgbEdit"); Page.ClientScript.RegisterForEventValidation("rptD ata$ctl" + String.Format("{0:00}", i) + "$imgbDelete"); RegisterRequiresPostBack(rptData.Items[i].Controls[1]); RegisterRequiresPostBack(rptData.Items[i].Controls[3]); } base.Render(writer); }
---------------------------------------------------------------------------------------------------------------------------
I obtained the unique ID's for the controls by iterating through the controls in each row of the repeater to find them and then used the following code above to try and register them. However this does not seem to solve the problem so i think i'm not obtaining the right ID's for the controls or i'm missing something else or not understanding the requirements of the function. In case anyone is wondering the RegisterRequiresPostBack() function was added after i read a suggestion to add it from another thread referencing the same exception, but this does not seem to solve the problem either.
Any help would be greatful, otherwise i'll have to resort to turning off event validation which ideally i don't want to do.
Kind Regards,
Tim Anderson This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Peter Kirk |
last post by:
Hi
are there any "gotchas" with using an asp:repeater that means that the
"onclick" method of a LinkButton created in the repaeter does not fire?
I at least cannot get it to work. I have a...
|
by: LIN |
last post by:
i have an asp repeater which is bound at runtime from a dataset ...it looks
like this
Name Age DOB
xxxx 234 7/9/07
yyyy 234 7/9/07
here all rows in the name column are hyperlink...
|
by: JD |
last post by:
Hello,
I have a problem with checkboxlist inside Repeater (in ASP.NET page).
I am able to create Checkboxlist and bind it (inside Repeater_ItemBound -
including setting checked/unchecked)....
|
by: WebMatrix |
last post by:
I am struggling with implementing somewhat complicated UI web-control. I
explored Repeater, but I am not sure if it's the best way to go. I am leaning
towards writing my own custom control and...
|
by: dhnriverside |
last post by:
Hi
I'm using an asp:repeater and its DataSource/DataBind system to show a
number of records from the database. I want to highlight the latest record
(which will be the highest ID).
Any...
|
by: dhnriverside |
last post by:
Hi
I want to use an Asp:Repeater to create a list of items. I want the list to
be 3 columns wide, and order like so...
AA AD AG
AB AE AH
AC AF AI
I'm not...
|
by: Neo Geshel |
last post by:
I am looking to add additional data into a "stream" that has been
extracted from a database, but before it is sent to a control (Repeater,
in this case).
I have found ZERO (0) articles about...
|
by: Fred Dag |
last post by:
As far as I can work out when using the OnTextChanged event I cannot get the
TextBox and Labels values when the event fires as they are populated by a
<asp:repeater and so don't have values.
If...
|
by: semomaniz |
last post by:
I have a button inside a repeater which is supposed to open a popup when clicked. But when i click on the button my modalpopup does not open. The strange thing is on the code provided below if i...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM).
In this month's session, the creator of the excellent VBE...
|
by: MeoLessi9 |
last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
|
by: DolphinDB |
last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation.
Take...
|
by: Aftab Ahmad |
last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below.
Dim IE As Object
Set IE =...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: marcoviolo |
last post by:
Dear all,
I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
| |