views:

131

answers:

1

Hey Everyone,

I've found that when using the

<!-- include file="MyPage.aspx" -->

command in ASP, I'm not able to use the code-behind in MyPage.aspx.

The issue is that when I try to include MyPage.aspx, there is an error because we have two Page Directives. If I remove the Page Directive, I can include MyPage.aspx just fine, but cannot access the code-behind, because the "CodeBehind" parameter in the Page Directive is no longer there.

So, as far as I can tell, we have a Catch-22. Does anyone know of a work-around for this? Or is there just something I'm missing?

Thanks, -Onion-Knight

I'm not sure if this changes anything, but I am using a Master Page with the page that includes MyPage.aspx.

+5  A: 

Why don't you use a user control (*.ascx) instead of including an aspx page?

Have a look at this overview in MSDN which shows how to create and user "user controls".

M4N