PC Review


Reply
Thread Tools Rate Thread

user control property

 
 
Guoqi Zheng
Guest
Posts: n/a
 
      19th Mar 2004
Dear sir,

I have Page Header user control. On my main page, I have the following code.

<uc1:header id="MyHeader" runat="server"
PageName="OurProducts.aspx"></uc1:header>

PageName property is a public variable inside that user control. When I put
the value of PageName inside the html code, everything works ok. However, I
would like to determine the value of PageName by coding. So I do the
following.

public Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
MyHeader.PageName = "Others.aspx"
End Sub

When I tried to compile the code, I always get an error of Name "MyHeader"
not declared.

Can someone point out what I did wrong here? I am using VS.NET 2003

--
Met vriendelijke groet,

Guoqi Zheng
Tel: +31 (0) 23 5407422
Mob: 0648252520
http://www.meetholland.com


 
Reply With Quote
 
 
 
 
=?Utf-8?B?QmlsbCBCb3Jn?=
Guest
Posts: n/a
 
      19th Mar 2004
In your code-behind, do: protected withevents MyHeader as header, where MyHeader *must* match whatever you use for ID of the instance of the control on your page, and header is the name of the user control class

----- Guoqi Zheng wrote: ----

Dear sir

I have Page Header user control. On my main page, I have the following code

<uc1:header id="MyHeader" runat="server
PageName="OurProducts.aspx"></uc1:header

PageName property is a public variable inside that user control. When I pu
the value of PageName inside the html code, everything works ok. However,
would like to determine the value of PageName by coding. So I do th
following

public Sub Page_Load(ByVal sender As System.Object, ByVal e A
System.EventArgs) Handles MyBase.Loa
MyHeader.PageName = "Others.aspx
End Su

When I tried to compile the code, I always get an error of Name "MyHeader
not declared

Can someone point out what I did wrong here? I am using VS.NET 200

-
Met vriendelijke groet

Guoqi Zhen
Tel: +31 (0) 23 540742
Mob: 064825252
http://www.meetholland.co



 
Reply With Quote
 
 
 
 
Kevin Spencer
Guest
Posts: n/a
 
      19th Mar 2004
Yo need to declare the header variable in the CodeBehind script if you want
to manipulate it there. Something like:

Protected MyHeader As header

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Guoqi Zheng" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Dear sir,
>
> I have Page Header user control. On my main page, I have the following

code.
>
> <uc1:header id="MyHeader" runat="server"
> PageName="OurProducts.aspx"></uc1:header>
>
> PageName property is a public variable inside that user control. When I

put
> the value of PageName inside the html code, everything works ok. However,

I
> would like to determine the value of PageName by coding. So I do the
> following.
>
> public Sub Page_Load(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles MyBase.Load
> MyHeader.PageName = "Others.aspx"
> End Sub
>
> When I tried to compile the code, I always get an error of Name "MyHeader"
> not declared.
>
> Can someone point out what I did wrong here? I am using VS.NET 2003
>
> --
> Met vriendelijke groet,
>
> Guoqi Zheng
> Tel: +31 (0) 23 5407422
> Mob: 0648252520
> http://www.meetholland.com
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
User Control to Control Other User Control Jonathan Wood Microsoft ASP .NET 4 2nd Feb 2010 04:41 PM
persisting changes to a control outside a user control from the user control? Mad Scientist Jr Microsoft ASP .NET 0 22nd Mar 2006 09:02 AM
Compile errors when using form control's "Control Source" property to refer to the control's value Yarik Mezheritskiy Microsoft Access Form Coding 3 5th Nov 2004 02:56 AM
Control designer for custom user control property Rhy Mednick Microsoft Dot NET Framework Forms 1 18th Jun 2004 09:18 AM
The controls on this property sheet are disabled because one or more other Network property sheets are already open. To use these controls, close all these property sheets and then reopen this one. =?Utf-8?B?Um9iZXJ0?= Microsoft Windows 2000 Networking 1 11th Apr 2004 12:22 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:02 AM.