Wrox Programmer Forums
|
ASP.NET 1.x and 2.0 Application Design Application design with ASP.NET 1.0, 1.1, and 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.x and 2.0 Application Design 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
 
Old December 24th, 2003, 12:54 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default FindControl Method problem

Hello all, Happy Holidays

This is what I have.
I have a Usercontrol(.ascx) with 1 control on it. (this is a third party control for a menu) it is called CMSMenuListBar.ascx. The control is named "uwlbCMSMenu"

in my aspx page I want to set some properties of this control (uwlbCMSMenu)

This is my code
    Protected WithEvents CMSMenu As CMSMenuListBar

PageLoad:
            Dim x As Infragistics.WebUI.UltraWebListbar.UltraWebListbar
            x = CMSMenu.FindControl("uwlbCMSMenu")
            x.SelectedGroup = 1

I complile and run, but keep getting this error:
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:


Line 125: Dim x As Infragistics.WebUI.UltraWebListbar.UltraWebListbar
Line 126: ' x = CType(CMSMenu.FindControl("uwlbCMSMenu"), Infragistics.WebUI.UltraWebListbar.UltraWebListbar )
Line 127: x = CMSMenu.FindControl("uwlbCMSMenu")
Line 128: x.SelectedGroup = 1
Line 129:


Line 127 is hightlighted as the error.

It seems like it is not finding that control, but that is the correct name. Am I missing something? Am I doing something wrong?

Any help would be appreciated.

Thanks,

Jim


 
Old December 29th, 2003, 10:39 AM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

This turned out to be an issue with instanciating the user control. If anyone is interested I will go into more detail.

 
Old March 7th, 2004, 05:17 PM
Registered User
 
Join Date: Mar 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to redgabber
Default

I have the same prb... how to solved ir ? thx

 
Old March 8th, 2004, 10:32 AM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

I had to instanciate the object. At the top of the page, I put this:

    Protected WithEvents CMSMenuListBar1 As CMSMenuListBar

Then you can access methods and properties like any other control.

Hope this helps.





Similar Threads
Thread Thread Starter Forum Replies Last Post
FindControl in DataListItem SKhna ASP.NET 2.0 Basics 1 February 29th, 2008 05:15 PM
FindControl in nested repeater chrisk_47 .NET Framework 2.0 0 February 6th, 2007 10:45 PM
FindControl Wervis C# 7 November 30th, 2005 09:51 AM
FindControl dkr72 Excel VBA 0 January 19th, 2005 09:55 AM
Problem with FindControl RussC Excel VBA 1 June 16th, 2004 11:58 AM





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