cfinclude functionality in ASP.NET

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Trying to achieve this functionality in ASP.NET.
<cfif NOT session.loggedin>
<cfinclude template="loginPage.cfm">
<cfelse>
<cfif session.loginType EQ "Instructor">
... show Instructor menu...
<cfif form.menuItem EQ 1>
<cfinclude template="MenuItem1Page.cfm">
<cfelseif form.menuItem EQ 2>
.......
</cfif>
<cfelseif session.loginType EQ "Reviewer">
... show Reviewer menu ...
... includes for Reviewers
</cfif>
</cfif>
Trying nested master pages but having trouble implementing the nesting
(Whidbey beta 1). Also not sure how to navigate between NOT logged in and
logged in and among menuItem pages. Thanks in advance.
 
I'm not familiar with Cold Fusion, but I know it is similar to ASP. So,
forgive me if I interpret you incorrectly, but it sure looks like your
"cfinclude" tag is, in essence, a dynamic include file. If so, as ASP.Net is
object-oriented, you would want to create a class instead, either a User
Control (if you want to use a template) or a Server Control (which is a pure
class), and conditionally create an instance of it and place it in your
page.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Ambiguity has a certain quality to it.
 
Thanks, Kevn. You inferred correctly re Cold Fusion. I think a structure
like this would work - pseudocode:
Main.master (<html><links><meta> etc.)
if not logged in then
LoginRoutine.aspx
elseif login successful then
if user is Instructor then
Instructor.master (containing menu options)
InstructorFunction_1.aspx
......
InstructorFunction_N.aspx
elseif user is Reviewer then
Reviewer.master (containing reviewer menu options)
ReviewerFuntion_1.aspx
....
ReviewerFuntion_N.aspx
endif
endif

I think I've figured out the basic plumbing of nested masters since my
original post.
But still not sure of best way to transfer from page to page. Have been
doing the following which seems to work but it's unappealing:

httpContext.Current.Response.Redirect(xxx.aspx) in a content page's
Load_Page method.

Is there a better way?
 
I really don't think you want nested pages. What you want is a User Control
(which is almost like a Page, but is designed to be used IN a page), or a
Server Control. Or you may want to do a Response.Redirect or a
Server.Transfer to a differrent page.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Ambiguity has a certain quality to it.
 
Thanks, Kevin.
I guess you mean something like this schematically:
InstructorFunctions.aspx with these:
User control ID = menu
User control ID = InstructorFunction_1 (Invoked conditionally)
User control ID = InstructorFunction_2 (Invoked conditionally)
....
User control ID = InstructorFunction_1 (Invoked conditionally)

I'll try this.
 
Hi Peter,

That looks about right to me! :)

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Ambiguity has a certain quality to it.
 
Hi Peter,

Also, if you're using User Controls, be aware that they CAN be conditionally
loaded (that is, not be in the Page Template, but loaded into the Page at
run-time). This is done by using the Page.LoadControl() method.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Ambiguity has a certain quality to it.
 
Got it! Have the menu working now as user control. With ViewState enabled,
using
Page_Load()
{
if(!IsPostBack)
{
... add menu items here ...
}
}

Love the tip on Page.LoadControl().

Thanks,

Peter
 

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

Back
Top