Re: Invalid FORMATETC structure (Exception from HRESULT: 0x80040064(DV_E_FORMATETC))
- From: "Allan Ebdrup" <ebdrup@xxxxxxxxxxxxxxx>
- Date: Tue, 31 Jan 2006 13:54:56 +0100
"Neil Ni" <v-neilni@xxxxxxxxxxxxxxxxxxxx> wrote in message
news:Jdc137kJGHA.3152@xxxxxxxxxxxxxxxxxxxxxxxx
> Do you build a custom web control and when you drag and drop this control
> from toolbox, it displayed that error?
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
.
- Follow-Ups:
- References:
- Prev by Date: GridViewUpdateEventArgs not including complete set of OldValues and NewValues
- Next by Date: Re: GridViewUpdateEventArgs not including complete set of OldValues and NewValues
- Previous by thread: RE: Invalid FORMATETC structure (Exception from HRESULT: 0x80040064(DV_E_FORMATETC))
- Next by thread: Re: Invalid FORMATETC structure (Exception from HRESULT: 0x80040064(DV_E_FORMATETC))
- Index(es):
Relevant Pages
|