Label in different User Control File 
Author Message
 Label in different User Control File

How can I control the text of a label in a user control file that is
inherited into my page?

eg.

mypage.aspx -> mypage.aspx.vb

within mypage.aspx is mycontrol.ascx

there is a label in mycontrol.ascx which I need to update from
mypage.aspx.vb

I tried the regular way of

public Label thislabel;
...
thislabel.Text = "thisvalue"

but it gives me a "Object reference not set to an instance of an
object. " error.

anyone have any ideas?

Mark



Sun, 14 Nov 2004 04:13:23 GMT  
 Label in different User Control File
Hello Mark,

You must ensure that object was initialized before you reference on of its
property. You may try the code below:

Public thislabel As Label = New Label()

thislabel.Text = "thisvalue"

Hope it helps.

Best regards,

Lion Shi, MCSE, MCSD
Microsoft Support Engineer

This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use.  2001 Microsoft Corporation. All rights
reserved.
--------------------

    Newsgroups: microsoft.public.dotnet.languages.CSharp
    Subject: Label in different User Control File
    Date: 28 May 2002 13:13:23 -0700
    Organization: http://groups.google.com/
    Lines: 24

    NNTP-Posting-Host: 208.187.182.253
    Content-Type: text/plain; charset=ISO-8859-1
    Content-Transfer-Encoding: 8bit
    X-Trace: posting.google.com 1022616803 21072 127.0.0.1 (28 May 2002
20:13:23 GMT)

    NNTP-Posting-Date: 28 May 2002 20:13:23 GMT
    Path:
cpmsftngxa08!tkmsftngp01!newsfeed00.sul.t-online.de!t-online.de!skynet.be!sk
ynet.be!proxad.net!proxad.net!isdnet!sn-xit-02!supernews.com!postnews1.googl
e.com!not-for-mail
    Xref: cpmsftngxa08 microsoft.public.dotnet.languages.csharp:64036
    X-Tomcat-NG: microsoft.public.dotnet.languages.csharp

    How can I control the text of a label in a user control file that is
    inherited into my page?

    eg.

    mypage.aspx -> mypage.aspx.vb

    within mypage.aspx is mycontrol.ascx

    there is a label in mycontrol.ascx which I need to update from
    mypage.aspx.vb

    I tried the regular way of

    public Label thislabel;
    ...
    thislabel.Text = "thisvalue"

    but it gives me a "Object reference not set to an instance of an
    object. " error.

    anyone have any ideas?

    Mark



Mon, 15 Nov 2004 14:15:28 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. User Controls: Accessing Properties (a slightly different point of view)

2. Sending messages to ActiveX user interface controls from a different thread

3. Horrible user control bug stripped all user controls from my project

4. Two labels with two different fonts!

5. Globals in different files, different types, same names

6. compile different source files with different exception handling

7. Different resource files for different project settings???

8. Same EVC + Different PC's = arm exe DIFFERENT file size (iPAQ)

9. ASP.NET Newbie - pass a Var from Code Behind to User Control file

10. Source Control prompts users about checking out .dsp files

11. Create Process as a different user

12. how to changed ad's user's password with csharp (different server)

 

 
Powered by phpBB® Forum Software