473,886 Members | 2,366 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Each time I do a postback, another copy of a control is added to the page!

Hi everyone,

I'm having a really weird problem with one of my pages. Whenever I hit the
submit button, it reloads the page but another side menu control appears
underneath the original one. This will occur as many times as I hit the
submit button. The thing that I don't understand is that I'm *not* adding
the controls dynamically. The html for the page is very very simple and is
basically the following without the body/head tags etc:

<table width="85%" border="0" cellspacing="0" cellpadding="2" >
<tr>
<td width="151" valign="top">
<uc1:sidemenuco ntrol id="SideMenuCon trol1"
runat="server"> </uc1:sidemenucon trol>
</td>
<td>
<uc1:UserRolesC ontrol id="UserRolesCo ntrol1"
runat="server"> </uc1:UserRolesCo ntrol>
</td>
</tr>
</table>

The control that is repeating itself is the SideMenuControl . I don't know
why because it just displays menu elements. Admittedly those elements are
added dynamically but it seems to be that the whole menu is being added each
time, leading me to believe that the problem lies with the (very simple)
containing page.

Can anyone help with this?

I' would be very greatful for any help

Thanks

Simon
Nov 18 '05 #1
5 1192
In the controls page_load wrap the code in:

if(!IsPostBack) {
//add your code here
}

See if that helps.

Alan Washington
http://www.aewnet.com

Hi everyone,

I'm having a really weird problem with one of my pages. Whenever I hit the
submit button, it reloads the page but another side menu control appears
underneath the original one. This will occur as many times as I hit the
submit button. The thing that I don't understand is that I'm *not* adding
the controls dynamically. The html for the page is very very simple and is
basically the following without the body/head tags etc:

<table width="85%" border="0" cellspacing="0" cellpadding="2" >
<tr>
<td width="151" valign="top">
<uc1:sidemenuco ntrol id="SideMenuCon trol1"
runat="server"> </uc1:sidemenucon trol>
</td>
<td>
<uc1:UserRolesC ontrol id="UserRolesCo ntrol1"
runat="server"> </uc1:UserRolesCo ntrol>
</td>
</tr>
</table>

The control that is repeating itself is the SideMenuControl . I don't know
why because it just displays menu elements. Admittedly those elements are
added dynamically but it seems to be that the whole menu is being added each
time, leading me to believe that the problem lies with the (very simple)
containing page.

Can anyone help with this?

I' would be very greatful for any help

Thanks

Simon


User submitted from AEWNET (http://www.aewnet.com/)
Nov 18 '05 #2
What does the Load event handler look like for the user control?
Is that where you dynamically build the menu elements?
--
Scott
http://www.OdeToCode.com/blogs/scott/

On Fri, 22 Oct 2004 14:40:34 +0100, "Simon Harvey"
<sh856531@micro softs_free_emai l_service.com> wrote:
Hi everyone,

I'm having a really weird problem with one of my pages. Whenever I hit the
submit button, it reloads the page but another side menu control appears
underneath the original one. This will occur as many times as I hit the
submit button. The thing that I don't understand is that I'm *not* adding
the controls dynamically. The html for the page is very very simple and is
basically the following without the body/head tags etc:

<table width="85%" border="0" cellspacing="0" cellpadding="2" >
<tr>
<td width="151" valign="top">
<uc1:sidemenuco ntrol id="SideMenuCon trol1"
runat="server" ></uc1:sidemenucon trol>
</td>
<td>
<uc1:UserRolesC ontrol id="UserRolesCo ntrol1"
runat="server" ></uc1:UserRolesCo ntrol>
</td>
</tr>
</table>

The control that is repeating itself is the SideMenuControl . I don't know
why because it just displays menu elements. Admittedly those elements are
added dynamically but it seems to be that the whole menu is being added each
time, leading me to believe that the problem lies with the (very simple)
containing page.

Can anyone help with this?

I' would be very greatful for any help

Thanks

Simon


Nov 18 '05 #3
Hi Guys,

You were both right. I realised what was going on shortly after asking for
help.

I took the if(!IsPostback) line out in order to debug something

I'm a twat.

Thanks very much for your help

Kindest Regards

Simon
Nov 18 '05 #4
Simon,
If this is a user control that you consume only and don't want to mess
with the code, try disabling its viewstate. That's probably the issue. Or
if this is your user control, wrap the Load logic in a test for
Page.IsPostBack

Best regards,
Jeffrey Palermo

"Simon Harvey" <sh856531@micro softs_free_emai l_service.com> wrote in message
news:Oj******** ******@TK2MSFTN GP12.phx.gbl...
Hi everyone,

I'm having a really weird problem with one of my pages. Whenever I hit the
submit button, it reloads the page but another side menu control appears
underneath the original one. This will occur as many times as I hit the
submit button. The thing that I don't understand is that I'm *not* adding
the controls dynamically. The html for the page is very very simple and is
basically the following without the body/head tags etc:

<table width="85%" border="0" cellspacing="0" cellpadding="2" >
<tr>
<td width="151" valign="top">
<uc1:sidemenuco ntrol id="SideMenuCon trol1"
runat="server"> </uc1:sidemenucon trol>
</td>
<td>
<uc1:UserRolesC ontrol id="UserRolesCo ntrol1"
runat="server"> </uc1:UserRolesCo ntrol>
</td>
</tr>
</table>

The control that is repeating itself is the SideMenuControl . I don't know
why because it just displays menu elements. Admittedly those elements are
added dynamically but it seems to be that the whole menu is being added each time, leading me to believe that the problem lies with the (very simple)
containing page.

Can anyone help with this?

I' would be very greatful for any help

Thanks

Simon

Nov 18 '05 #5
Thanks guys. I was just being very stupid.

I took the if !IsPostBack line out in order to debug something else. Forgot
to put it back in.

I'll remember the symptoms of that particular mistake. It wasnt something
I'd ever seen before.

Very odd

:-)

Simon
Nov 18 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
5493
by: DotNetJunky | last post by:
I have built a control that runs an on-line help system. Depending on the category you selected via dropdownlist, it goes out and gets the child subcategories, and if there are any, adds a new dropdownlist to the screen for selection. This continues until there are no children, and then it checks for a help article list based on that last selection and displays actual articles for display. Adding the controls and getting everything...
3
2161
by: Rubble | last post by:
Hello, Ive placed a server control button on my aspx page. Ive created some client side script that Ive tied to the onclick action of this button. The script adds to a listbox the contents of a textbox. It works very well, but the page does a postback, and the listbox resets itself. The listbox has to be a server control, so I cant create this whole scenario using your basic client side javascript.
2
5010
by: Sam | last post by:
I have a custom control (MyTextBox - taken from Microsoft website) that implements the IPostBackDataHandler interface. It is added to the controls collection of a placeholder control during the Page Load of a main ASPX page. Now if we debug the MyTextBox, we find the order of events like so (during a Posback, of course): OnInit -> OnLoad -> LoadPostData. My question is why does the LoadPostData occur *after* the OnLoad instead of...
1
2807
by: Marcel Balcarek | last post by:
I create a user control dynamically: Dim newCriteriaControl As CriteriaTextBoxUserControl = CType(Me._page.LoadControl("CriteriaTextBoxUserControl.ascx"), CriteriaTextBoxUserControl) myContainer.Add(newCriteriaControl) and the user control's load event executes on initial executon of the page. On a POST of the same page, the control is added as above, but the load event is not firing, nor is prerender.
1
5383
by: Angel | last post by:
I have added controls to the placeholder control. All the controls that were added have EnableViewState = true including the placeholder. One of the controls has a button that performs a postback. My question is when the button is clicked and a postback is performed, the controls that were in the placeholder no longer appears on the screen! Am I doing something wrong here? Why are the controls back on the screen eventhough they have enable view...
21
24477
by: Martin Eyles | last post by:
I am trying to get javascript to cause a page to post back. I have tried calling _doPostBack from my script, but generates an error "object expected". I think this is because the page's script doesn't contain the method _doPostBack, which needs to be added by asp.net. How can I make asp.net add this script? Thanks, ME --
2
2500
by: Alan Silver | last post by:
Hello, I'm having rather a problem with user control. It is a fairly simple affair (see my other threads for more details) that shows a date and time in five drop down controls. I had private member variables for the day, month, year, hour and minute, and the public property that sets the DateTime simply stored the relevant numbers in these variables.
7
3029
by: Shimon Sim | last post by:
I have a custom composite control I have following property
13
1518
by: tshad | last post by:
Is there a way to run a script or function on entry of each page without having to put a call in each page? Periodically, I find something I want to do each time a page is entered and I have to go into each page and add a line or 2 in my asp.net code. That's a lot of pages and I could easily miss one. For example, I have a user object that I built that I just added a field - LastPageVisited. This was necessary because, apparently,...
0
11172
Oralloy
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10770
jinu1996
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10872
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7987
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7139
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6010
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4627
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4235
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3245
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.