473,800 Members | 3,038 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Exposing properties of a user control to the web forms page

http://msdn.microsoft.com/library/de...ercontrols.asp

Following the above example I created a usercontrol and added it to another
web form MyPage.aspx. Then I added code to declare the user control as
instructed in the above article:

' Visual Basic menu as a user control
Public Class MyPage
Inherits System.Web.UI.P age
Protected WithEvents Label1 As System.Web.UI.W ebControls.Labe l
Protected Menu1 As menu

But if I try to make a call to menu1 (menu1.itemname = "test") it screams at
me that the object has not been created and is still "nothing". When/how
does the user control object (menu1) get created. What step am I missing
here.

Thanks in advance,

Jason
Nov 18 '05 #1
1 1219
Are you putting your code in the OnLoad event handler? You can't access this
control until it has completed loading.

--
Chris Jackson
Software Engineer
Microsoft MVP - Windows Client
Windows XP Associate Expert
--
More people read the newsgroups than read my email.
Reply to the newsgroup for a faster response.
(Control-G using Outlook Express)
--

"Jason" <jd***@yahoo.co m> wrote in message
news:ec******** ******@tk2msftn gp13.phx.gbl...
http://msdn.microsoft.com/library/de...ercontrols.asp

Following the above example I created a usercontrol and added it to
another
web form MyPage.aspx. Then I added code to declare the user control as
instructed in the above article:

' Visual Basic menu as a user control
Public Class MyPage
Inherits System.Web.UI.P age
Protected WithEvents Label1 As System.Web.UI.W ebControls.Labe l
Protected Menu1 As menu

But if I try to make a call to menu1 (menu1.itemname = "test") it screams
at
me that the object has not been created and is still "nothing". When/how
does the user control object (menu1) get created. What step am I missing
here.

Thanks in advance,

Jason

Nov 18 '05 #2

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

Similar topics

8
3365
by: deko | last post by:
I'm hoping someone can sanity check my understanding of the Object Model for Forms/Controls. I'm having trouble drilling down into Control properties. First, I have a record set with the following for a given Form: 1)Container
3
14165
by: Chris | last post by:
Hi, I'm trying to append text from another class to a generic richTextBox that I've added to a Windows form. I can't seem to figure out how to expose the richTextBox to append text to it. Thanks in advance, Chris
10
7374
by: Sunny | last post by:
Hi, I have an old problem which I couldn't solve so far. Now I have found a post in that group that gave me an idea, but I can not fully understand it. The problem is: I'm trying to use a Windows.Forms.UserControl in a COM environment, i.e. I want to host that control in a COM host. So far, so good, I can host it, but I can not reach the parent COM object from the control (Parent property is null :( ). I have stopped the control in the...
3
6634
by: countd4 | last post by:
I have built a working user control. However, to make it work, I always have to set certian properties using the properties sheet for the control when using it on other forms. I want to be able to set default values for most properties so the control will work as-is without requiring the developer to set them. I notice in the compment initialization code create when I drop the control on a form that all the properties are set to null or...
2
3350
by: wh | last post by:
I have a user control implemented in an .ascx page that I embed in the html as follows: <test:mycontrol runat="server" property1="..." property2="..."/> I'd also like to be able to assign a collection of strings to a property called 'items' but am unsure of whether this is possible, and if so how it can be done. I'd presumably have a property in the codebehind .cs file for the .ascx
2
3186
by: Brian | last post by:
NOTE ALSO POSTED IN microsoft.public.dotnet.framework.aspnet.buildingcontrols I have solved most of my Server Control Collection property issues. I wrote an HTML page that describes all of the problems that I have encountered to date and the solutions (if any) that I found. http://users.adelphia.net/~brianpclab/ServerControlCollectionIssues.htm This page also has all of the source code in a compressed file that you are free to download...
1
1801
by: Mark | last post by:
I have an aspx page that contains a usercontrol. The usercontrol is titled 'authorize'. 'authorize' contains 2 panel 'login' and 'logout'. Both are by default 'not visible' I want to set one of them, dependingn on whether the user IsAutheticated (forms), to visible. Whe I put the following code in my aspx page: Sub Page_Load If User.Identity.IsAuthenticated Then authorize.pnlLogin.Visible = False
6
11083
by: | last post by:
I have made some user controls with custom properties. I can set those properties on instances of my user controls, and I have programmed my user control to do useful visual things in response to how those properties are set. I want to be able to do two other things: a) add User control instances to my page, filling in the place of placeholder controls, and b) programmatically setting custom properties on those dynamically spawned...
2
2210
by: =?Utf-8?B?RGFsZQ==?= | last post by:
I have an app with a MasterPage. In the MasterPage is a user control with several public properties and methods that I want exposed to the content page. Rather than writing several redirection methods to expose the properties, I would rather just expose the user control as a property of the MasterPage. The problem is, when I compile, I get an exception on the content page: The type 'MessageBlock.MessageBlock' is defined in an...
0
9550
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10501
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...
1
10250
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,...
0
10032
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6811
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
5603
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4149
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
3764
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2944
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.