PostBack Problems

R

rn5a

I have 2 ListBoxes which get populated with records from a database.
The Form has a Button as well. Note that users can select multiple
items in both the ListBoxes.

When a user selects items from the 1st ListBox & clicks the Button,
the selected items get deleted from the 1st ListBox & get appended to
the 2nd ListBox at the very end. I also want that the items that have
just got appended to the 2nd ListBox should also get selected. In
other words, to view the just appended items in the 2nd ListBox, I
don't want users to scroll down the 2nd ListBox to view the newly
appended items. Instead, the 2nd ListBox should automatically scroll
down after the items get appended to the 2nd ListBox.

I am trying to do this using JavaScript (using the OnClientClick event
of the Button server control) but ASP.NET generates the following
error:

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.

I tried to overcome this error by adding the following code:

Protected Overrides Sub Render(ByVal writer As HtmlTextWriter)
MyBase.Render(writer)
ClientScript.RegisterForEventValidation(lstBox1.ID)
End Sub

but that doesn't make any difference. The error still persists.

If I set EnableEventValidation to False in the Page directive, then
the error doesn't get generated but at the same time, the items
selected in the 1st ListBox do not get appended to the 2nd ListBox.

Can someone please give me some idea on how do I overcome this error?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,074
Latest member
StanleyFra

Latest Threads

Top