Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. VS2005 - Declaring page objects in the business layer

VS2005 - Declaring page objects in the business layer

Scheduled Pinned Locked Moved ASP.NET
winformsbusinesshelpquestion
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Dr_X
    wrote on last edited by
    #1

    In 2003 I would pass a page object and other information to the business layer so that common functionality can be execute in one location for all pages. e.g. validating users, setting up menus, setting the webform state (editmode/readonly), etc... However, in VS2005 I am unable to declare variables in the business layer as a webform, masterpage or usercontrol. I even changed the partial class to public for those web types. Is there a work-around I am missing? Below the following user controls and master pages cannot be declared to a variable: IAC.Training.usercontrols.pagetabs, IAC.Training.Web.MasterMain. Error is 'Type ... is not defined'. Basically, just about every page would access the following code to create the webform's menus/submenus. There is no sense in placing the code in every form. Any ideas?

    Namespace IAC.Training.BusinessLayer

    Public Class Search
    Inherits BusinessLogicLayerSearchBase

    Sub New(ByVal uID As Integer, ByVal page As Control)
      MyBase.new(uID, page)
    End Sub
    
    Public Sub InitializeMenus(ByVal currentTabName As String)
      Dim page As Page = CType(Me.Page, Page)'From the base class
      Dim subTabs As IAC.Training.usercontrols.pagetabs = page.FindControl("subTabs", IAC.Training.usercontrols.pagetabs)
    
      'Load Menus
      CType(page.Master, IAC.Training.Web.MasterMain).InitMenu(True, IAC.Training.Web.MasterMain.MenuTabs.Search.ToString)
      subTabs.DataSource = SubTabCollection()
      subTabs.IsChildMenuTabs = True
      subTabs.CurrentTabName = currentTabName
      subTabs.DataBind()
    End Sub
    

    Thanks, Michael I firmly believe that any man's finest hour, the greatest fulfillment of all that he holds dear, is that moment when he has worked his heart out in a good cause and lies exhausted on the field of battle - victorious. Vince Lombardi (1913-1970) -- modified at 12:00 Wednesday 12th April, 2006

    M 1 Reply Last reply
    0
    • D Dr_X

      In 2003 I would pass a page object and other information to the business layer so that common functionality can be execute in one location for all pages. e.g. validating users, setting up menus, setting the webform state (editmode/readonly), etc... However, in VS2005 I am unable to declare variables in the business layer as a webform, masterpage or usercontrol. I even changed the partial class to public for those web types. Is there a work-around I am missing? Below the following user controls and master pages cannot be declared to a variable: IAC.Training.usercontrols.pagetabs, IAC.Training.Web.MasterMain. Error is 'Type ... is not defined'. Basically, just about every page would access the following code to create the webform's menus/submenus. There is no sense in placing the code in every form. Any ideas?

      Namespace IAC.Training.BusinessLayer

      Public Class Search
      Inherits BusinessLogicLayerSearchBase

      Sub New(ByVal uID As Integer, ByVal page As Control)
        MyBase.new(uID, page)
      End Sub
      
      Public Sub InitializeMenus(ByVal currentTabName As String)
        Dim page As Page = CType(Me.Page, Page)'From the base class
        Dim subTabs As IAC.Training.usercontrols.pagetabs = page.FindControl("subTabs", IAC.Training.usercontrols.pagetabs)
      
        'Load Menus
        CType(page.Master, IAC.Training.Web.MasterMain).InitMenu(True, IAC.Training.Web.MasterMain.MenuTabs.Search.ToString)
        subTabs.DataSource = SubTabCollection()
        subTabs.IsChildMenuTabs = True
        subTabs.CurrentTabName = currentTabName
        subTabs.DataBind()
      End Sub
      

      Thanks, Michael I firmly believe that any man's finest hour, the greatest fulfillment of all that he holds dear, is that moment when he has worked his heart out in a good cause and lies exhausted on the field of battle - victorious. Vince Lombardi (1913-1970) -- modified at 12:00 Wednesday 12th April, 2006

      M Offline
      M Offline
      minhpc_bk
      wrote on last edited by
      #2

      Because the compiling model is changed in the ASP.NET 2.0, so I think you cannot access the dynamic class (of the web page, master page or the user control) in a custom class like that. Here are a couple of options come to mind: + You can place your sample code in a web page, user control or master page, then use the Reference[^] directive to programmatically access the classes like the pagetabs, MasterMain ... + You may think of creating the base class for the master page or user control so that you can use this base class in your business layer. + Because you said every page would access that sample code, so IMHO you may place the code right in the master page and the user control.

      D 1 Reply Last reply
      0
      • M minhpc_bk

        Because the compiling model is changed in the ASP.NET 2.0, so I think you cannot access the dynamic class (of the web page, master page or the user control) in a custom class like that. Here are a couple of options come to mind: + You can place your sample code in a web page, user control or master page, then use the Reference[^] directive to programmatically access the classes like the pagetabs, MasterMain ... + You may think of creating the base class for the master page or user control so that you can use this base class in your business layer. + Because you said every page would access that sample code, so IMHO you may place the code right in the master page and the user control.

        D Offline
        D Offline
        Dr_X
        wrote on last edited by
        #3

        Thanks. I was hoping I was simply missing something quick & easy to implement the techniques. The app is ported from version 1.1 of .net As far as the reference directive, the pages already have them for the controls. I knew I could create base classes or interfaces but again was hoping not to have to go through all of the pages. Putting the code in the master page is something I didn't think about. I take a look at possibly putting the common code here away from the business layer. Thanks I firmly believe that any man's finest hour, the greatest fulfillment of all that he holds dear, is that moment when he has worked his heart out in a good cause and lies exhausted on the field of battle - victorious. Vince Lombardi (1913-1970)

        D M 2 Replies Last reply
        0
        • D Dr_X

          Thanks. I was hoping I was simply missing something quick & easy to implement the techniques. The app is ported from version 1.1 of .net As far as the reference directive, the pages already have them for the controls. I knew I could create base classes or interfaces but again was hoping not to have to go through all of the pages. Putting the code in the master page is something I didn't think about. I take a look at possibly putting the common code here away from the business layer. Thanks I firmly believe that any man's finest hour, the greatest fulfillment of all that he holds dear, is that moment when he has worked his heart out in a good cause and lies exhausted on the field of battle - victorious. Vince Lombardi (1913-1970)

          D Offline
          D Offline
          Dr_X
          wrote on last edited by
          #4

          I ended up using both interfaces and base classes to create the functionality needed to interact with the webtype classes with in the business layer.

          Public Interface IMasterPage
          Sub InitMenu(ByVal hasChildMenuTabs As Boolean, ByVal currentTabName As String)
          End Interface

          Public Sub InitializeMenus(ByVal currentTabName As String)
          
          
            'MasterPage menus 'Uses the IMasterPage inteface
            CType(MyBase.Page.Master, IAC.Training.Web.IMasterPage).InitMenu(True, currentTabName)
          
          
            'Current page menus uses the inherited BaseTabMenu to expose the needed methods in the usercontrol
            Dim subTabs As IAC.Training.Web.BaseTabMenu = CType(Page.FindControl("subTabs"), IAC.Training.Web.BaseTabMenu)
            With subTabs
              .CurrentTabName = currentTabName
              .IsChildMenuTabs = True
              .DataSource = SubTabCollection()
              .DataBind()
            End With
          
          End Sub
          

          Thanks again Michael I firmly believe that any man's finest hour, the greatest fulfillment of all that he holds dear, is that moment when he has worked his heart out in a good cause and lies exhausted on the field of battle - victorious. Vince Lombardi (1913-1970) -- modified at 11:02 Thursday 13th April, 2006

          1 Reply Last reply
          0
          • D Dr_X

            Thanks. I was hoping I was simply missing something quick & easy to implement the techniques. The app is ported from version 1.1 of .net As far as the reference directive, the pages already have them for the controls. I knew I could create base classes or interfaces but again was hoping not to have to go through all of the pages. Putting the code in the master page is something I didn't think about. I take a look at possibly putting the common code here away from the business layer. Thanks I firmly believe that any man's finest hour, the greatest fulfillment of all that he holds dear, is that moment when he has worked his heart out in a good cause and lies exhausted on the field of battle - victorious. Vince Lombardi (1913-1970)

            M Offline
            M Offline
            minhpc_bk
            wrote on last edited by
            #5

            Hi Michael, There is another option that you might also want to try, I mean you can try the VS 2005 Web Project[^] which is an add-in for VS 2005 (it's still RC though). With this option, you may not change your code, and you can easily access the classes of the web page and user control as you would with VS 2003, :cool:!

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups