Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Cannot add custom control to toolbox - why not?

Reply
Thread Tools

Cannot add custom control to toolbox - why not?

 
 
James Radke
Guest
Posts: n/a
 
      12-18-2003
Hello,

I am creating a custom vb.net web control. This control is a timer that
will automatically postback to the server (see
http://www.eggheadcafe.com/articles/20021006.asp for C# source that I am
trying to translate to vb)

Every time I try to add the control to the toolbox (using add/remove items
then browsing to the DLL on my test web server) in a new web project I get
an error which says that I cannot load the DLL, check the dependencies. I
have no idea why this does not allow me add my custom control to the toolbox
so that I can drag/drop it into my project.

Can anyone help me out? I don't know what is going on.....

The source code follows:

Thanks!

Jim

==== WebTimer.VB ========

Imports System
Imports System.IO
Imports System.Drawing
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.Design
Imports System.Web.UI.WebControls
Imports System.ComponentModel
Imports System.ComponentModel.Design
Imports System.Text

Namespace Stratecon.Web

<ToolboxDataAttribute("<{0}:WebTimer runat=""server""></{0}:WebTimer>"),
_
DefaultEventAttribute("Elapsed"), _
ToolboxBitmapAttribute(GetType(Bitmap), "Stratecon.Web.WebTimer.bmp"),
_
DesignerAttribute("Stratecon.Web.TimerDesigner",
"Stratecon.Web.Timer")> _
Public Class Timer
Inherits Control
Implements IPostBackEventHandler

Private iInterval As Integer = 5000
Private bEnabled As Boolean = True
Private bEnableViewState As Boolean = True
Public Event Elapsed As EventHandler
<BindableAttribute(True), _
CategoryAttribute("WebTimer"), _
DescriptionAttribute("Whether WebTimer Control is enabled."), _
BrowsableAttribute(True)> _
Public Property Enabled() As Boolean
Get
Return bEnabled
End Get
Set(ByVal Value As Boolean)
bEnabled = Value
End Set
End Property

<BindableAttribute(False), _
BrowsableAttribute(False)> _
Public Overrides Property EnableViewState() As Boolean
Get
Return bEnableViewState
End Get
Set(ByVal Value As Boolean)
bEnableViewState = Value
End Set
End Property

<CategoryAttribute("WebTimer"), _
BrowsableAttribute(True), _
DescriptionAttribute("Number of milliseconds WebTimer waits until
firing a postback."), _
BindableAttribute(True)> _
Public Property Interval() As Integer
Get
Return iInterval
End Get
Set(ByVal Value As Integer)
iInterval = Value
End Set
End Property

Protected Overrides Sub OnInit(ByVal e As EventArgs)

End Sub

Public Sub RaisePostBackEvent(ByVal eventArgument As String) _
Implements IPostBackEventHandler.RaisePostBackEvent
OnElapsed(New EventArgs)
End Sub

Public Sub OnElapsed(ByVal ea As EventArgs)
RaiseEvent Elapsed(Me, ea)
End Sub

Protected Overrides Sub Render(ByVal output As HtmlTextWriter)
If Enabled Then
'* Create the Javascript postback "setTimeout" Page Timer
code:
'<script language="javascript">
'<!--
'setTimeout( "__doPostBack('PgTimer1','')", 5000);
'// -->
'</script>
'*/
Dim sb As New StringBuilder
sb.Append("\n<script language=\""javascript\""> \n <!-- \n
setTimeout( \")
sb.Append(MyBase.Page.GetPostBackEventReference(Me ))
sb.Append("\n ,")
sb.Append(iInterval.ToString())
sb.Append("); \n // --> \n </script>")
output.Write(sb.ToString())
End If
End Sub

End Class

End Namespace


==== webtimer.designer.vb =======

Imports System
Imports System.ComponentModel
Imports System.ComponentModel.Design
Imports System.Reflection
Imports System.Web.UI.Design
Imports System.Web.UI.WebControls
Imports System.Web.UI
Imports System.Web

Namespace Stratecon.Web

Public Class TimerDesigner
Inherits System.Web.UI.Design.ControlDesigner

Private webtimer As New Stratecon.Web.Timer

Public Overrides Function GetDesignTimeHtml() As String
Return "<label id=\'Lbl1\' style=\'align: center; COLOR:Blue;
valign: middle; background-color:FFCC66; border-width:2px;\'
>WebTimer</label>"

End Function

Public Overrides Sub Initialize(ByVal component As IComponent)
webtimer = component
MyBase.Initialize(component)
End Sub
End Class

End Namespace


 
Reply With Quote
 
 
 
 
Jeffrey Tan[MSFT]
Guest
Posts: n/a
 
      12-19-2003

Hi James,

I will do some research for you. I will reply you ASAP.
Thanks for your understanding.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

 
Reply With Quote
 
 
 
 
James Radke
Guest
Posts: n/a
 
      12-19-2003
Jeffrey,

I figured out most of my issues, and the control is working well... except
for one thing:

The control I am building has no graphical interface, yet I would like the
control to show up as a literal (or perhaps as an bitmap image) in the
VS.NET 2003 designer so I can see it is on the page when I am modifying /
building the page; and to make it easy to click on it and modify the
properties.

I thought the following code:

Public Overrides Function GetDesignTimeHtml() As String
Dim sw As New StringWriter
Dim tw As New HtmlTextWriter(sw)

Dim controllabel As New Label

' Put simple.Text into the link's Text.
controllabel.Text = "WebTimer"
controllabel.ForeColor = System.Drawing.Color.Blue
controllabel.BackColor = System.Drawing.Color.Cornsilk
controllabel.RenderControl(tw)

Return sw.ToString()
'Return "<span style='align: center; COLOR:Blue; valign: middle;
background-color:FFCC66; border-width:2px;'>WebTimer</span>"
End Function

in the designer module would do that; yet, in the designer, my control
always shows up as just the green arrow showing a control with some weird
lines right next to it? How do I make it so that it either appears as a
literal, or an image file?

Thanks!

Jim

""Jeffrey Tan[MSFT]"" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>
> Hi James,
>
> I will do some research for you. I will reply you ASAP.
> Thanks for your understanding.
>
> Best regards,
> Jeffrey Tan
> Microsoft Online Partner Support
> Get Secure! - www.microsoft.com/security
> This posting is provided "as is" with no warranties and confers no rights.
>



 
Reply With Quote
 
Jeffrey Tan[MSFT]
Guest
Posts: n/a
 
      12-22-2003

Hi James,

I am glad that you worked out your original problem.
For your following question, actually you can do customize UI in
GetDesignTimeHtml.
This MSDN article talks about this:
http://msdn.microsoft.com/library/de...us/vbcon/html/
vbwlkWalkthroughCreatingCustomWebControls.asp

Also another article provide you a good sample of design-time support of
web form:
http://msdn.microsoft.com/library/de...us/dnaspp/html
/aspnet-adddesigntimesupport.asp

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

 
Reply With Quote
 
Jiho Han
Guest
Posts: n/a
 
      12-22-2003
James,

What did you do to resolve your issue with the toolbox because I am having
the same problem?

Thanks much.

"James Radke" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Jeffrey,
>
> I figured out most of my issues, and the control is working well... except
> for one thing:
>
> The control I am building has no graphical interface, yet I would like the
> control to show up as a literal (or perhaps as an bitmap image) in the
> VS.NET 2003 designer so I can see it is on the page when I am modifying /
> building the page; and to make it easy to click on it and modify the
> properties.
>
> I thought the following code:
>
> Public Overrides Function GetDesignTimeHtml() As String
> Dim sw As New StringWriter
> Dim tw As New HtmlTextWriter(sw)
>
> Dim controllabel As New Label
>
> ' Put simple.Text into the link's Text.
> controllabel.Text = "WebTimer"
> controllabel.ForeColor = System.Drawing.Color.Blue
> controllabel.BackColor = System.Drawing.Color.Cornsilk
> controllabel.RenderControl(tw)
>
> Return sw.ToString()
> 'Return "<span style='align: center; COLOR:Blue; valign:

middle;
> background-color:FFCC66; border-width:2px;'>WebTimer</span>"
> End Function
>
> in the designer module would do that; yet, in the designer, my control
> always shows up as just the green arrow showing a control with some weird
> lines right next to it? How do I make it so that it either appears as a
> literal, or an image file?
>
> Thanks!
>
> Jim
>
> ""Jeffrey Tan[MSFT]"" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> >
> > Hi James,
> >
> > I will do some research for you. I will reply you ASAP.
> > Thanks for your understanding.
> >
> > Best regards,
> > Jeffrey Tan
> > Microsoft Online Partner Support
> > Get Secure! - www.microsoft.com/security
> > This posting is provided "as is" with no warranties and confers no

rights.
> >

>
>



 
Reply With Quote
 
Jiho Han
Guest
Posts: n/a
 
      12-22-2003
@#$%!

The only problem was that my .dll was located on a mapped drive(on the
network) when I was trying to add to the toolbox.
Once I moved it to a local folder, it added with no problem.

Ironically, I ignore the warning message that popped up when I set my
project folder to the mapped path - some security stuff and the project may
not execute correctly due to the lack of full trust, blah blah. Goes to
show that you should really heed the warning messages however trivial it
seems at the moment...

"Jiho Han" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> James,
>
> What did you do to resolve your issue with the toolbox because I am having
> the same problem?
>
> Thanks much.
>
> "James Radke" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
> > Jeffrey,
> >
> > I figured out most of my issues, and the control is working well...

except
> > for one thing:
> >
> > The control I am building has no graphical interface, yet I would like

the
> > control to show up as a literal (or perhaps as an bitmap image) in the
> > VS.NET 2003 designer so I can see it is on the page when I am modifying

/
> > building the page; and to make it easy to click on it and modify the
> > properties.
> >
> > I thought the following code:
> >
> > Public Overrides Function GetDesignTimeHtml() As String
> > Dim sw As New StringWriter
> > Dim tw As New HtmlTextWriter(sw)
> >
> > Dim controllabel As New Label
> >
> > ' Put simple.Text into the link's Text.
> > controllabel.Text = "WebTimer"
> > controllabel.ForeColor = System.Drawing.Color.Blue
> > controllabel.BackColor = System.Drawing.Color.Cornsilk
> > controllabel.RenderControl(tw)
> >
> > Return sw.ToString()
> > 'Return "<span style='align: center; COLOR:Blue; valign:

> middle;
> > background-color:FFCC66; border-width:2px;'>WebTimer</span>"
> > End Function
> >
> > in the designer module would do that; yet, in the designer, my control
> > always shows up as just the green arrow showing a control with some

weird
> > lines right next to it? How do I make it so that it either appears as a
> > literal, or an image file?
> >
> > Thanks!
> >
> > Jim
> >
> > ""Jeffrey Tan[MSFT]"" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed)...
> > >
> > > Hi James,
> > >
> > > I will do some research for you. I will reply you ASAP.
> > > Thanks for your understanding.
> > >
> > > Best regards,
> > > Jeffrey Tan
> > > Microsoft Online Partner Support
> > > Get Secure! - www.microsoft.com/security
> > > This posting is provided "as is" with no warranties and confers no

> rights.
> > >

> >
> >

>
>



 
Reply With Quote
 
James Radke
Guest
Posts: n/a
 
      12-23-2003
Jiho,

I had to laugh because that is the same exact issue I was having! Since I
don't have a local webserver I am using a remote one for testing, and it
never occurred to me (at first) that I couldn't simply reference the remote
BIN directory....

Just goes to show you that is is always the simple things that get you.....


Glad you figured it out!

Jim

"Jiho Han" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> @#$%!
>
> The only problem was that my .dll was located on a mapped drive(on the
> network) when I was trying to add to the toolbox.
> Once I moved it to a local folder, it added with no problem.
>
> Ironically, I ignore the warning message that popped up when I set my
> project folder to the mapped path - some security stuff and the project

may
> not execute correctly due to the lack of full trust, blah blah. Goes to
> show that you should really heed the warning messages however trivial it
> seems at the moment...
>
> "Jiho Han" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > James,
> >
> > What did you do to resolve your issue with the toolbox because I am

having
> > the same problem?
> >
> > Thanks much.
> >
> > "James Radke" <(E-Mail Removed)> wrote in message
> > news:%(E-Mail Removed)...
> > > Jeffrey,
> > >
> > > I figured out most of my issues, and the control is working well...

> except
> > > for one thing:
> > >
> > > The control I am building has no graphical interface, yet I would like

> the
> > > control to show up as a literal (or perhaps as an bitmap image) in the
> > > VS.NET 2003 designer so I can see it is on the page when I am

modifying
> /
> > > building the page; and to make it easy to click on it and modify the
> > > properties.
> > >
> > > I thought the following code:
> > >
> > > Public Overrides Function GetDesignTimeHtml() As String
> > > Dim sw As New StringWriter
> > > Dim tw As New HtmlTextWriter(sw)
> > >
> > > Dim controllabel As New Label
> > >
> > > ' Put simple.Text into the link's Text.
> > > controllabel.Text = "WebTimer"
> > > controllabel.ForeColor = System.Drawing.Color.Blue
> > > controllabel.BackColor = System.Drawing.Color.Cornsilk
> > > controllabel.RenderControl(tw)
> > >
> > > Return sw.ToString()
> > > 'Return "<span style='align: center; COLOR:Blue; valign:

> > middle;
> > > background-color:FFCC66; border-width:2px;'>WebTimer</span>"
> > > End Function
> > >
> > > in the designer module would do that; yet, in the designer, my control
> > > always shows up as just the green arrow showing a control with some

> weird
> > > lines right next to it? How do I make it so that it either appears as

a
> > > literal, or an image file?
> > >
> > > Thanks!
> > >
> > > Jim
> > >
> > > ""Jeffrey Tan[MSFT]"" <(E-Mail Removed)> wrote in message
> > > news:(E-Mail Removed)...
> > > >
> > > > Hi James,
> > > >
> > > > I will do some research for you. I will reply you ASAP.
> > > > Thanks for your understanding.
> > > >
> > > > Best regards,
> > > > Jeffrey Tan
> > > > Microsoft Online Partner Support
> > > > Get Secure! - www.microsoft.com/security
> > > > This posting is provided "as is" with no warranties and confers no

> > rights.
> > > >
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

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
[NEWBIE] How to add a custom control to the toolbox! Jeff ASP .Net 1 12-17-2006 04:08 PM
findcontrol("PlaceHolderPrice") why why why why why why why why why why why Mr. SweatyFinger ASP .Net 2 12-02-2006 03:46 PM
Can not add SQLDataAdapter control to toolbox in Visual Web Developer tom c ASP .Net 1 09-07-2006 12:58 AM
Cannot drag custom web control from toolbox C Townhill ASP .Net Web Controls 3 03-24-2005 01:41 AM
add custom control to toolbox Prasanna Padmanabhan ASP .Net 0 07-03-2003 07:49 PM



Advertisments