Search:
Namespaces
Discussions
.NET v1.1
Feedback
newbie Custom Control problems..
Messages
Related Types
This message was discovered on
ASPFriends.com 'aspngcontrolsvb' list
.
Srini
Hi All,
I created a custom control. Given below is the .vb file , which i compiled. When i try to use it in a .aspx page, i get the following error.
Compiler Error Message: BC30560: 'CustomControl1' is ambiguous in the namespace 'MyCustomControls'
I have not been able to figure out the problem..Anybody please help me. Also in the aspx file i would like to know what exactly is ACME:customcontrol1 . can it be called anything other than customcontrol1 also??
And finally, does the .dll have to be in the bin folder inside the root folder. Will the .aspx page not recognise it if it is not in the bin folder??
Thanks & Regards
Srini
CustomControl.VB source file
Imports System
Imports System.Web
Imports System.Web.UI
Namespace MyCustomControls
Public Class CustomControl1 : Inherits Control
Private strMessage as String = " This is my custom control"
Public Property Message as String
Get
Message=strMessage
End Get
Set
strMessage=value
End Set
End Property
Protected Overrides Sub Render(Output as HtmlTextWriter)
Output.Write(strMessage & " The time is now" & _
DateTime
.Now.ToString)
End Sub
End class
End Namespace
.aspx file
<%@ Page Language="VB" %>
<%@ Register TagPrefix="ACME" Namespace="MyCustomControls" Assembly="CustomControl" %>
<html><body>
<form runat="server">
The Custom control produces the following output:<p>
<ACME:CustomControl1 id="MyControl" runat="server" Message="Hello World" />
</form>
</body></html>
Reply to this message...
Jeffrey Widmer
Srini,
ACME:customcontrol1 is how your custom control is identified in the aspx
page. Take a look at the Register directive at the top of you aspx page:
<%@ Register TagPrefix="ACME" Namespace="MyCustomControls"
Assembly="CustomControl" %>
This tells you that whenever you want to use your custom control in the aspx
page, you can specify it by the short tag ACME. It also says that ACME will
refer to the classes within the Namespace MyCustomControls. And finally,
your custom control is contained in the assembly called CustomControl.dll.
Chances are you are getting the ambiguous error because both the custom
control class and possible another aspx's code behind class are named the
same (customcontrol1) and both are sitting within the same namespace.
That's just a guess.
Also remember to watch out for VB's default namespace settings in the
project properties.
Lastly, the bin directory is the default location that the web application
will look for assemblies. I am not sure if you can specify another location
for .net web applications to find assemblies (other than putting them in the
GAC).
Hope this helps,
-Jeff
-----Original Message-----
From: Srini [mailto:
Click here to reveal e-mail address
]
Sent: Wednesday, January 30, 2002 12:51 PM
To: aspngcontrolsvb
Subject: [aspngcontrolsvb] newbie Custom Control problems..
Hi All,
I created a custom control. Given below is the .vb file , which i compiled.
When i try to use it in a .aspx page, i get the following error.
Compiler Error Message: BC30560: 'CustomControl1' is ambiguous in the
namespace 'MyCustomControls'
I have not been able to figure out the problem..Anybody please help me. Also
in the aspx file i would like to know what exactly is ACME:customcontrol1 .
can it be called anything other than customcontrol1 also??
And finally, does the .dll have to be in the bin folder inside the root
folder. Will the .aspx page not recognise it if it is not in the bin
folder??
Thanks & Regards
Srini
CustomControl.VB source file
Imports System
Imports System.Web
Imports System.Web.UI
Namespace MyCustomControls
Public Class CustomControl1 : Inherits Control
Private strMessage as String = " This is my custom control"
Public Property Message as String
Get
Message=strMessage
End Get
Set
strMessage=value
End Set
End Property
Protected Overrides Sub Render(Output as HtmlTextWriter)
Output.Write(strMessage & " The time is now" & _
DateTime
.Now.ToString)
End Sub
End class
End Namespace
.aspx file
<%@ Page Language="VB" %>
<%@ Register TagPrefix="ACME" Namespace="MyCustomControls"
Assembly="CustomControl" %>
<html><body>
<form runat="server">
The Custom control produces the following output:<p>
<ACME:CustomControl1 id="MyControl" runat="server" Message="Hello
World" />
</form>
</body></html>
| [aspngcontrolsvb] member
Click here to reveal e-mail address
= YOUR ID
|
http://www.asplists.com/asplists/aspngcontrolsvb.asp
= JOIN/QUIT
|
http://www.asplists.com/search
= SEARCH Archives
Reply to this message...
Srini
Hi Jeff,
How can i find out wat are the cusom controls sittting under the namespace
and and if it is possible to remove them from a particular namespace
Regards
Srini
----- Original Message -----
From: "Jeffrey Widmer" <
Click here to reveal e-mail address
>
To: "aspngcontrolsvb" <
Click here to reveal e-mail address
>
Sent: Thursday, January 31, 2002 3:41 AM
Subject: [aspngcontrolsvb] RE: newbie Custom Control problems..
[Original message clipped]
Reply to this message...
Srini
Hi all,
Since, I havent got a reply even after two days..thought i would repost it
again..
How can i find out wat are the cusom controls sittting under the namespace
and and if it is possible to remove them from a particular namespace
Regards
Srini
----- Original Message -----
From: "Srini" <
Click here to reveal e-mail address
>
To: "aspngcontrolsvb" <
Click here to reveal e-mail address
>
Sent: Saturday, February 02, 2002 10:02 PM
Subject: [aspngcontrolsvb] RE: newbie Custom Control problems..
[Original message clipped]
Reply to this message...
Alex Lowe
Remember, if you follow the rules at =
(
http://www.aspfriends.com/aspfriends/aspngescalate.asp
?tab=3Drules" target="_blank">
http://www.aspfriends.com/aspfriends/aspngescalate.asp
?tab=3Drules) =
then you can escalate your problem to [aspngescalate] =
(
http://www.aspfriends.com/aspfriends/aspngescalate.asp
).
Alex Lowe
AspFriends.com Moderation Team
----- Original Message -----
From: "Srini" <
Click here to reveal e-mail address
>
To:
Click here to reveal e-mail address
Sent: Mon, 4 Feb 2002 21:58:32 +0530
Subject: Re: [aspngcontrolsvb] RE: newbie Custom Control problems..
Hi all,
Since, I havent got a reply even after two days..thought i would repost =
it
again..
How can i find out wat are the cusom controls sittting under the =
namespace
and and if it is possible to remove them from a particular namespace
Regards
Srini
----- Original Message -----
From: "Srini" <
Click here to reveal e-mail address
>
To: "aspngcontrolsvb" <
Click here to reveal e-mail address
>
Sent: Saturday, February 02, 2002 10:02 PM
Subject: [aspngcontrolsvb] RE: newbie Custom Control problems..
[Original message clipped]
the
> > same (customcontrol1) and both are sitting within the same =
namespace.
[Original message clipped]
Reply to this message...
Jeffrey Widmer
Srini,
Since these are controls that you build, they don't have to be removed from
any namespace, but you have to set the namespace correctly.
There are several places where your namespace can be set. In VS.Net,
right-click on the project and select properties. Then select common
properties, General and change the Root Namespace to whatever you want it to
be. All of your classes in this project will now be within this namespace.
You can also set the namespace in code by using the Namespace ... End
Namespace lines, with your class inside those namepsace lines.
To see what namespace your control is in, use the object browser.
If you are still having problems, post some more of your code. You also
might want to think about posting to aspngfreeforall since this is a general
question regarding namespaces and how they work and is getting offtrack
here.
-Jeff
-----Original Message-----
From: Srini [mailto:
Click here to reveal e-mail address
]
Sent: Monday, February 04, 2002 11:29 AM
To: aspngcontrolsvb
Subject: [aspngcontrolsvb] RE: newbie Custom Control problems..
Hi all,
Since, I havent got a reply even after two days..thought i would repost it
again..
How can i find out wat are the cusom controls sittting under the namespace
and and if it is possible to remove them from a particular namespace
Regards
Srini
----- Original Message -----
From: "Srini" <
Click here to reveal e-mail address
>
To: "aspngcontrolsvb" <
Click here to reveal e-mail address
>
Sent: Saturday, February 02, 2002 10:02 PM
Subject: [aspngcontrolsvb] RE: newbie Custom Control problems..
[Original message clipped]
| [aspngcontrolsvb] member
Click here to reveal e-mail address
= YOUR ID
|
http://www.asplists.com/asplists/aspngcontrolsvb.asp
= JOIN/QUIT
|
http://www.asplists.com/search
= SEARCH Archives
Reply to this message...
System.DateTime
System.Web.UI.HtmlTextWriter
Ad
MBR BootFX
Best-of-breed application framework for .NET projects, developed by Matthew Baxter-Reynolds and MBR IT
Copyright © Matthew Baxter-Reynolds 2001-2008. '.NET 247 Software Development Services' is a trading style of MBR IT Solutions Ltd.
Contact Us
-
Terms of Use
-
Privacy Policy
-
www.dotnet247.com