PC Review


Reply
Thread Tools Rate Thread

ASP.Net user control

 
 
RCIC
Guest
Posts: n/a
 
      5th Dec 2003
If I add a user control to a webform, it seems like I
should be able to make it visable or invisable. My code
doesn't seem to work. I made a control called myControl
and dragged to on to my web form. I then added this to
the code behind and ran it.

Public test As myControl

Private Sub Page_Load(ByVal sender .....
test.Visible = False
End Sub

The error I get is: Object reference not set to an
instance of an object. Any idea what my problem is?
 
Reply With Quote
 
 
 
 
trinitypete
Guest
Posts: n/a
 
      5th Dec 2003
When you add the user control to the web form it places
references in the HTML:

At the top of the HTML Document
<%@ Register TagPrefix="uc1" TagName="ucpager"
Src="UserControls/ucPager.ascx" %>

And at the place where you added the control
<TD>
<uc1:ucpager id="PageHeaderControl"
runat="server"></uc1:ucpager>
<TD>

what you need to do is add a reference in the code behind
as follows:

protected namespace.controltype controlname
where control name matches the ID in the HTML so in the
example above:
protected namespacewhatever.ucpager PageHeaderControl


now you can access the properties i.e.
PageHeaderControl.Visible

>-----Original Message-----
>If I add a user control to a webform, it seems like I
>should be able to make it visable or invisable. My code
>doesn't seem to work. I made a control called myControl
>and dragged to on to my web form. I then added this to
>the code behind and ran it.
>
> Public test As myControl
>
> Private Sub Page_Load(ByVal sender .....
> test.Visible = False
> End Sub
>
>The error I get is: Object reference not set to an
>instance of an object. Any idea what my problem is?
>.
>

 
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
Populate data in one user control based on selection in another user control rajarameshvarma@gmail.com Microsoft C# .NET 1 28th Aug 2006 10:25 AM
Showing a WaitDialog user control while another user control is loading BobRoyAce Microsoft Dot NET Framework Forms 0 20th Jul 2006 04:38 AM
Custom User Control is not rendered inside another user control in a server table. Leeor Chernov Microsoft ASP .NET 2 16th Oct 2005 09:35 AM
User control embedded in user control not recognizing events jw56578@gmail.com Microsoft Dot NET 0 29th Mar 2005 02:22 AM
Event not firing for user control inside user control vatech1993 Microsoft ASP .NET 4 11th Dec 2004 02:51 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:35 PM.