Page posts back after having already performed a postback

G

Guest

I have a form containing three AJAX UpdatePanels, two of which contain a pair
of listboxes and a pair of buttons, with the third one containing a pair of
radio buttons in a radiobutton list and either three CascadingDropDown lists
or two CascadingDropDown lists and a textbox depending on which radio button
is selected. The only other control on my form is a button to submit the
information on the form to the server.

One thing I've noticed is the information gets posted back to the server
twice when the button is clicked. This causes a duplicate record to be
written to two tables and a SQL exception being thrown when it tries to write
a duplicate record to a third table since it violates that table's primary
key constraint. At first, I thought the cause might've been due to having
the submit button in the third UpdatePanel I mentioned, so I removed it from
the UpdatePanel and placed it by itself ... but the problem still occurs.
One other thing I've noticed is that when data for one of the UpdatePanels is
to be updated via a postback to the server, the other two UpdatePanels act as
if they're also being posted back to the server; in other words, all three
panels noticeably flicker simultaneously. I have a sneaking suspicion this
may somehow tie into my entire page being posted back twice when the submit
button is clicked, but I'm not at all sure.

What can I do to prevent my page from being posted back twice?
 
G

Guest

I've had something similar recently. Theoretically, if you set the
UpdateMode to "conditional" on each of the UpdatePanels, then they should
just work independently. The Page_OnLoad event will still fire on each
postback, but the OnLoad event for the other panels shouldn't. I can't get
this to happen however. My workaround has been to determine what the sender
control is, and if I'm expecting it. E.g.
try
{
LinkButton myButton = (LinkButton)sender;
if(myButton.ID == "Expected value")
{
....
}
}
catch
{} //ignore
 

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,994
Messages
2,570,223
Members
46,812
Latest member
GracielaWa

Latest Threads

Top