Showing posts with label twice. Show all posts
Showing posts with label twice. Show all posts

Wednesday, March 28, 2012

Page with AJAX controls posts back twice to the server

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 the submit button being contained in the third UpdatePanel I mentioned, so I removed it from there 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?

Hi,

any sync postback at the server side is almost identical to regual postback including:

- all control values are posted to the server
- Viewstate is transferred to the server and back

The most important difference is in the rendering phass: only update panels are rendered and their content transferred to the client

So, you must design your application in such a way, that removing all update panels will not break server logic. UpdatePanels reduce flickering, but they don't change how server code process data.

-yuriy


I think there a couple things that can cause this... I think ImageButtons can get rendered as "Submit" buttons, and have a __doPostBack call attached to their OnClick, which seems to make a double postback. Also, I think a button has a UseSubmitBehavior property... try setting that to false.

Saturday, March 24, 2012

Panel is resizing when it is used with RoundCornerExtender.It looks page load twice

hi

I have a master page , in that i have placed three panels and foreach panel i have a RoundedCornersExtender for round corners.problem iswhen i run the page it loads two times. I think that is because of roundcornerextender,when the page loads the panel looks to be resizing and it causes the page loads twice

when i remove the RoundedCornersExtender from the panel,it worksfine and load only once.but i want round corner panel for my masterpage to look good.


if anybody having the solution for this,plz advice me.Thanks in advance

This is my master page code

<%@dotnet.itags.org. Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %>
<%@dotnet.itags.org. Register Assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
Namespace="System.Web.UI" TagPrefix="asp" %
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
<link href="http://links.10026.com/?link=Hq_StyleSheet.css" rel="stylesheet" type="text/css" />
</head>
<body bgcolor="#4B5C82"><%--"#4B5C82"--%>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>

<table cellspacing="5" cellpadding="4" width="95%" align="center" id="mastertable">
<tr>
<td colspan="2">
<asp:Panel ID="panel1" runat="server" Width="100%" BackColor="#ffffff" >
<!--#include file="header.aspx"-->
</asp:Panel>

</td>
</tr>
<tr >
<td width="20%" height="100%" valign="top" >
<asp:Panel ID="panel2" runat="server" Width="100%" BackColor="#ffffff" Height="100%">
<table cellpadding="3"><tr><td>
<!--#include file="leftnav.aspx"-->
</td></tr>
</table>
</asp:Panel>
</td>
<td width="80%">
<asp:Panel ID="panel3" runat="server" Width="100%" BackColor="#ffffff" Height="100%">
<table cellpadding="3"><tr><td>
<asp:contentplaceholder id="middleContent" runat="Server"></asp:contentplaceholder>
//Content pages
</td></tr>
</table>
</asp:Panel>
</td>

</tr>
<tr>
<td></td>
<td id ="footer">
<!--#include file="footer.aspx"-->
</td>
</tr>
</table>
<ajaxToolkit:RoundedCornersExtender ID="RoundedCornersExtender1"runat="server" TargetControlID="Panel1" Radius="8"BorderColor="#ffffff">
</ajaxToolkit:RoundedCornersExtender>
<ajaxToolkit:RoundedCornersExtender ID="RoundedCornersExtender2"runat="server" TargetControlID="Panel2" Radius="8"BorderColor="#ffffff">
</ajaxToolkit:RoundedCornersExtender>
<ajaxToolkit:RoundedCornersExtender ID="RoundedCornersExtender3"runat="server" TargetControlID="Panel3" Radius="8"BorderColor="#ffffff">
</ajaxToolkit:RoundedCornersExtender>
</form>
</body>
</html>

Regards

Ajith

Hi Ajith,

My suggestion is you can wrap all contents in an div, and set this div's display property to "none" initially.

Then, add a pageLoad function to show it on client side. Like this:

function pageLoad()
{
$get("div's id").style.display = "block";
}

Hope this helps.


Hi Wen

Thank you Very much. it is working superb, but sometime when page loads, twice loading happens again(some times only).what would be the problem?

plz advice.Thank you very much once again

Regards

Ajith


It's hard to tell because I'm not able to reproduce that.

Can you make sure which element incurs a second postback?


Hi Wen

in my header page , i have menu for each page.for eg consider first menu
having a link to 1st page, in that page i having several textboxes and 1 dropdownlist
and cascadingdropdown and 1 auto complete extender.in that menu i clicked several times
only one time the page load twice.i think it may coz of processing time.

2nd having link to another page, in that page also i am having the same controls mentioned above and aditionally i am having ultrawebgrid(thirdpartycontrol,infragistics).i click
this menu also several time , in this case the pages seems like loading
twice so many times. idont know which control is making the problem.


This is the situation i am having.

Plz advice.

Regards

Ajith