Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Professional
| Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old April 24th, 2007, 01:08 PM
Registered User
 
Join Date: Apr 2007
Location: Mexico DF, , Mexico.
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to elmemo
Default WebUserControl IsPostBack == true, always

Hello.

  I'm writing this small web app that uses a web control I wrote inside of the "EditItemTemplate" portion of an ItemTemplate in a DetailsView. I got all the data binding working correctly. The web control I wrote depends on its own Page_Load to do the initialisation code, which must be run once (and only once) so it is wrapped in the usual "if !Ispostback ..." clause, the control's Page_Load is called by way of AutoEventWireup="true" property in the control.

  My problem is the control never evaluates the code, because IsPostBack is always true, even the first time the control is loaded into the DetailsView.

  I have tested the control outside of the detailsview and it works beautifully. Even on the same page, I have an instance of my control that does execute the page_load code, yet the one inside the EditItemTemplate in the DetailsView has this weird behaviour.

  Does anybody know what's going on? am I missing something here?

Thanks in advance
  #2 (permalink)  
Old April 29th, 2007, 03:18 AM
Registered User
 
Join Date: Apr 2007
Location: Mexico DF, , Mexico.
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to elmemo
Default

Well, I never was able to figure out why ispostback is allways true when a control resides inside the editItemTemplate, so what I did in the end was just cheaply fix this in page_load by calling init code in case it found the controls weren't populated yet.

Hope this helps someone

  #3 (permalink)  
Old May 1st, 2007, 08:47 PM
Registered User
 
Join Date: Apr 2007
Location: Mexico DF, , Mexico.
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to elmemo
Default

found an interesting link related to this: http://blogs.clearscreen.com/enadan/...2/21/2838.aspx

  #4 (permalink)  
Old May 3rd, 2007, 08:54 AM
Authorized User
 
Join Date: Dec 2004
Location: Swindon, Wilts, United Kingdom.
Posts: 68
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to DZukiewicz
Default

Don't controls have their own method of initialisation?

Try populate it in the Initialize() method, and not the Page_Load.
  #5 (permalink)  
Old May 4th, 2007, 05:09 PM
Registered User
 
Join Date: Apr 2007
Location: Mexico DF, , Mexico.
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to elmemo
Default

Hi DZukiewicz

I tried your method, and it works. I followed your advice and put the initialisation code at Page_Init and it's all good now.

Thanks a lot. Kind regards,

elmemo



Similar Threads
Thread Thread Starter Forum Replies Last Post
what is isPostBack amin_pucit ASP.NET 1.x and 2.0 Application Design 2 October 9th, 2013 06:30 AM
ASP.NET WebUserControl rao965 ASP.NET 2.0 Professional 4 November 12th, 2007 12:02 PM
IsPostBack() swastikagaur ASP.NET 1.0 and 1.1 Basics 3 March 18th, 2005 09:12 AM
Change style attribute of a WebUserControl YiannisF ASP.NET 1.0 and 1.1 Basics 1 July 10th, 2004 02:19 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.