The code in the class library is:
Basket.cs:
----------
using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
using System.Web.UI;
using System.ComponentModel;
namespace WebUI.Basket
{
[ParseChildren(true)]
class Basket : Control, INamingContainer
{
//public void Basket() { }
private ITemplate _headerTemplate = null;
[TemplateContainer(typeof(BasketHeader))]
public ITemplate Header
{
get
{
return _headerTemplate;
}
set
{
_headerTemplate = value;
}
}
// override to prevent literal controls from being added as children
protected override void AddParsedSubObject(object o)
{
}
protected override void CreateChildControls()
{
// if (Header != null)
// {
// create header
BasketHeader header = new BasketHeader();
// initialize header from template
Header.InstantiateIn(header);
// add header to the child controls collection
Controls.Add(header);
header = new BasketHeader();
// initialize header from template
Header.InstantiateIn(header);
// add header to the child controls collection
Controls.Add(header);
//}
}
}
}
----
BasketHeader.cs:
---
using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
using System.Web.UI;
using System.ComponentModel;
namespace WebUI.Basket
{
class BasketHeader : Control, INamingContainer
{
}
}
---
Can anyone help me with this?
Kind Regards,
Allan Ebdrup
Do you build a custom web control and when you drag and drop this control
from toolbox, it displayed that error?
It seems that something incorrect in your custom web control.
Here is an good article for your reference:
"Creating a Web Custom Control"
http://www.15seconds.com/issue/040421.htm
Thanks & Regards,
Neil Ni
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
=====================================================
Business-Critical Phone Support (BCPS) provides you with technical phone
support at no charge during critical LAN outages or "business down"
situations. This benefit is available 24 hours a day, 7 days a week to all
Microsoft technology partners in the United States and Canada.
This and other support options are available here:
BCPS:
https://partner.microsoft.com/US/technicalsupport/supportoverview/40010469
Others: https://partner.microsoft.com/US/technicalsupport/supportoverview/
If you are outside the United States, please visit our International
Support page:
http://support.microsoft.com/default.aspx?scid=%2finternational.aspx.
=====================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Yes
> It seems that something incorrect in your custom web control.
That's why I ask for help here
> Here is an good article for your reference:
>
> "Creating a Web Custom Control"
> http://www.15seconds.com/issue/040421.htm
I'm using VS.Net 2005 I've created a class library it has two classes, here
is the code:
Basket.cs:
---
using System;
using System.Collections;
using System.Web;
using System.Web.UI;
namespace OFiR.Web.Controls
{
[ParseChildren(true)]
class Basket : Control, INamingContainer
{
private ITemplate _headerTemplate = null;
[TemplateContainer(typeof(BasketHeader))]
public ITemplate Header
{
get
{
return _headerTemplate;
}
set
{
_headerTemplate = value;
}
}
// override to prevent literal controls from being added as children
protected override void AddParsedSubObject(object o)
{
}
protected override void CreateChildControls()
{
if (Header != null)
{
// create header
BasketHeader basketHeader = new BasketHeader();
// initialize header from template
Header.InstantiateIn(basketHeader);
// add header to the child controls collection
Controls.Add(basketHeader);
basketHeader = new BasketHeader();
// initialize header from template
Header.InstantiateIn(basketHeader);
// add header to the child controls collection
Controls.Add(basketHeader);
}
}
}
}
---
BasketHeader.cs
---
using System;
using System.Collections;
using System.Web;
using System.Web.UI;
namespace OFiR.Web.Controls
{
class BasketHeader : Control, INamingContainer
{
}
}
---
As you can see it's some very simple classes, and for some reason I get an
error when I try to drag and drop them onto my aspx page.
I've tried to create a new class library and start from scratch with the
same two classes but the same error occurs.
I've also tried the "Developing a Templated Databound Control" Example
described here:
http://samples.gotdotnet.com/quickstart/aspplus/default.aspx?url=%2fquickstart%2faspplus%2fdoc%2fwebctrlauthoring.aspx
The above example has almost identical code, and that control works
correctly, I simply can't spot the difference that produces the error, and I
don't find the error raised very informative. What causes the "Invalid
FORMATETC structure" error?
Can someone please help?
Kind Regards,
Allan Ebdrup