Casting to Interface at design time.

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?
 
M

Micke Andersson

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
 
P

Paul

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

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,043
Latest member
CannalabsCBDReview

Latest Threads

Top