Casting to Interface at design time.

  • Thread starter Thread starter Paul
  • Start date Start date
P

Paul

Hi all,

I am trying to cast my page to an Interface at design time with no joy.

sControl = ((IStatusPage)Page).[Interface code]

Despite this page 100% being inheriting this interface it will not
work.
I really do not want to cast to a class.

Any hints on where I am going wrong here?
 
Just as a hint .. if it doesn't work as stated, try rewriting it?

IStatusPage iPage = Page as IStatusPage;
if (iPage != null)
iPage.[interface code]

If nothing else, atleast you should be able to see if the "Page as
IStatusPage" is causing the problem, if so the class isn't interited from
IStatusPage after all.

/Micke
 
Sorry,

The code is just fine at runtime.

It is only in Design mode the problem exists.
It seems that the Visual Studio IDE does not bother
to process inheritance.

I should has mentioned that I am using an

if( Page is IStatusPage)

before the line I pasted.

So while your code will work it doesn't solve the actual problem.

Thanks for taking the time to reply though.

Paul

Micke said:
Just as a hint .. if it doesn't work as stated, try rewriting it?

IStatusPage iPage = Page as IStatusPage;
if (iPage != null)
iPage.[interface code]

If nothing else, atleast you should be able to see if the "Page as
IStatusPage" is causing the problem, if so the class isn't interited from
IStatusPage after all.

/Micke

Paul said:
Hi all,

I am trying to cast my page to an Interface at design time with no joy.

sControl = ((IStatusPage)Page).[Interface code]

Despite this page 100% being inheriting this interface it will not
work.
I really do not want to cast to a class.

Any hints on where I am going wrong here?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Invalid Cast Error 4
Force a cast 12
Interfaces and casting 2
Casting Rules 1
Casting issue 11
Casting Error 2
GridView bug? 2
Create user 1

Back
Top