View Single Post
  #4 (permalink)  
Old April 10th, 2008, 03:51 PM
froens froens is offline
Registered User
 
Join Date: Apr 2008
Location: Copenhagen, , Denmark.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to froens
Default

Hi there. I'm pretty new to all this .Net thing after playing for a while with JSP and PHP.

I'm experiencing some problems with the example on page 30-31. More exactly i'm having problems accessing the webparts at runtime/pageload time.

My code in the codebehind-file (i hope it's ok to post it here - if not, please direct me to where i'm supposed to post it):

namespace test1_webpart
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            this.WebPartZone1.WebParts[0].Title = "Search";
        }
    }
}

At runtime i get an error saying something about that my index is out of bounds. This could indicate that the Webparts collection is empty, which seems strange since the book explicitly says that collection is populated with generic webparts that acts as wrappers. What am I doing wrong ?

Just in case:
The web part zone WebPartZone1 is indeed containing controls which are supposed to be wrapped by web parts. These controls are the same as the ones the book suggests.

- Best Regards
  Frederik *^_^*