Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / July 2007

Tip: Looking for answers? Try searching our database.

Page posts back after having already performed a postback

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
AlBruAn - 23 Jul 2007 05:14 GMT
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?
rival@newsgroups.nospam - 23 Jul 2007 14:52 GMT
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

> 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
[quoted text clipped - 18 lines]
>
> What can I do to prevent my page from being posted back twice?

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.