The control already exists on the page. You just need to create a reference
to the control, not try and create a new control.

Delcare a reference to the control at the page level using the ID you
assigned in the HTML:

Private uCtlHeader as Header

Then you can reference it from any method on your page.

uCtlHeader.PageTitle = "This is the heading"

HTH,

Dean Fiala
-----------------------------
Very Practical Software, Inc.
http://www.vpsw.com/links.aspx




-----Original Message-----
From: Faisel Y! [mailto:[EMAIL PROTECTED]
Sent: Tuesday, August 17, 2004 11:58 PM
To: [EMAIL PROTECTED]
Subject: [AspNetAnyQuestionIsOk] Accessing user control's properties


I've created a user control Header which is a header with a page title. I
want to set the page title from code, so I've made it a property:

    Public Property PageTitle() As String
        Get
            Return lblHeading.Text
        End Get
        Set(ByVal Value As String)
            lblHeading.Text = Value
        End Set
    End Property

In the main page, I've dragged and dropped the user control on to my page,
I've created the control in my code-behind:

            Dim C1 As NEW Header
            C1.PageTitle = "This is the heading"

However, this is giving me an error: "Object reference not set to an
instance of an object"

I'm sure the name is right, so what I am missing. Here's the HTML where the
control is added:

 <uc1:Header id="uCtlHeader" runat="server"></uc1:Header>

I've tried
"Dim c1 As Header  = New Header"

but that didn't work either.

Please help me..

Thanks,
Faisel





Yahoo! Groups Links









------------------------ Yahoo! Groups Sponsor --------------------~--> 
Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar.
Now with Pop-Up Blocker. Get it for free!
http://us.click.yahoo.com/L5YrjA/eSIIAA/yQLSAA/saFolB/TM
--------------------------------------------------------------------~-> 

 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to