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 17015
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: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |