Solved

'SetPage' is not a member of 'System.Web.UI.MasterPage'. Error Help

Posted on 2014-02-07
6
618 Views
Last Modified: 2014-02-10
I've taken over a project from a co-worker developing a VB.Net (VS10) alternative to a VB6 application used within my org.  I was almost done with this project and my hard drive BSD'ed causing me to lose all my work.  (Side note...  Backup, backup, backup!!!)  Now with a new PC, new drivers, etc I'm starting fresh.  I've finally been able to get things in line to be able to code but when I debug this (F5) to just do basic testing this line within my login page is erroring out...  "'SetPage' is not a member of 'System.Web.UI.MasterPage'."  Maybe this points to additional driver issues?  Additionally within the login form I'm trying to debug it is not recognizing object on the webpage...  HELP!

        Dim MyMasterPage As MasterPage = DirectCast(Page.Master, MasterPage)
        MyMasterPage.SetPage()

Open in new window

0
Comment
Question by:EDW_Gideon
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 21

Expert Comment

by:Dale Burrell
ID: 39843794
My best guess is that the original project had a custom MasterPage class with the method SetPage, and that you haven't managed to recover this custom master page.

Its certainly not part of the regular MasterPage class.
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 39844255
You can access the public properties, methods, and events on the master page, if you use strong-typed master pages.

Working with ASP.NET Master Pages Programmatically
http://msdn.microsoft.com/en-us/library/c8y19k6h.ASPX
0
 

Author Comment

by:EDW_Gideon
ID: 39847660
Here's the masterpage, SetPage is a public Sub:

Imports System.Data.SqlClient
Imports System.Data
Imports System.Data.SqlDbType
Imports System.Web.UI.WebControls
Imports System.Web.UI
Partial Class MasterPage
    Inherits System.Web.UI.MasterPage
#Region " Control Events "
  Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    If Not IsPostBack Then
      SetPage()
    End If
  End Sub

#End Region
#Region " Header and Menu Functions "

  Public Sub SetPage()
    Dim dt As DataTable
    Dim dr As DataRow
    Dim i As Integer

    dt = New DataTable()
    dr = dt.NewRow()

    Try
      dt.Columns.Add("DisplayName")
      dt.Columns.Add("NavigateURL")
      dr.Item("DisplayName") = "Login"
      dr.Item("NavigateURL") = ConfigurationManager.AppSettings("Login")
      dt.Rows.Add(dr)
      dr = dt.NewRow()
      i = 0

      If Session.Contents("Create") = "Y" Then
        Session("DataSource") = "TDDD"
        If Session.Contents("UserSystem") = "TD16" Then
          dr.Item("DisplayName") = "Build User TD16"
        ElseIf Session.Contents("UserSystem") = "TD21" Then
          dr.Item("DisplayName") = "Build User TD21"
        ElseIf Session.Contents("UserSystem") = "TD25" Then
          dr.Item("DisplayName") = "Build User UDM"
          'dr.Item("DisplayName") = "Build User TD25"
        ElseIf Session.Contents("UserSystem") = "TD26" Then
          dr.Item("DisplayName") = "Build User TD26"
        ElseIf Session.Contents("UserSystem") = "TD27" Then
          dr.Item("DisplayName") = "Build User TD27"
        ElseIf Session.Contents("UserSystem") = "TD28" Then
          dr.Item("DisplayName") = "Build User TD28"
        ElseIf Session.Contents("UserSystem") = "TD29" Then
          dr.Item("DisplayName") = "Build User TD29"
        ElseIf Session.Contents("UserSystem") = "TD68" Then
          dr.Item("DisplayName") = "Build User UDM"
        Else
          Access_PL.Visible = True
          Return
        End If

        dr.Item("NavigateURL") = ConfigurationManager.AppSettings("Create_User")
        dt.Rows.Add(dr)
        dr = dt.NewRow()
        i = i + 1

      End If
      If Session.Contents("Access") = "Y" Then

        dr.Item("DisplayName") = "User Access"
        dr.Item("NavigateURL") = ConfigurationManager.AppSettings("Access")
        dt.Rows.Add(dr)
        dr = dt.NewRow()
        i = i + 1

      End If
      If Session.Contents("Password") = "Y" Then

        dr.Item("DisplayName") = "User Password"
        dr.Item("NavigateURL") = ConfigurationManager.AppSettings("Password")
        dt.Rows.Add(dr)
        dr = dt.NewRow()

        i = i + 1

      End If
      If Session.Contents("Maintain") = "Y" Then

        dr.Item("DisplayName") = "User Maintenance"
        dr.Item("NavigateURL") = ConfigurationManager.AppSettings("Maintain")
        dt.Rows.Add(dr)
        dr = dt.NewRow()
        i = i + 1

      End If

      dlMainMenu.DataSource = dt
      dlMainMenu.DataBind()

      If Session.Contents("page") = 0 Then
        dlMainMenu.SelectedIndex = "0"

      ElseIf Session.Contents("page") = 1 Then
        dlMainMenu.SelectedIndex = 1

      ElseIf Session.Contents("page") = 2 Then
        If Session.Contents("Create") = "Y" Then

          dlMainMenu.SelectedIndex = 2
        Else

          dlMainMenu.SelectedIndex = 1
        End If


      ElseIf Session.Contents("page") = 3 Then
        If Session.Contents("Create") = "N" And Session.Contents("Access") = "N" Then
          dlMainMenu.SelectedIndex = 1
        ElseIf Session.Contents("Create") = "Y" And Session.Contents("Access") = "N" Then
          dlMainMenu.SelectedIndex = 2
        ElseIf Session.Contents("Create") = "N" And Session.Contents("Access") = "Y" Then
          dlMainMenu.SelectedIndex = 2
        Else
          dlMainMenu.SelectedIndex = 3
        End If

      ElseIf Session.Contents("page") = 4 Then
        If Session.Contents("Create") = "N" And Session.Contents("Access") = "N" And Session.Contents("Password") = "N" Then
          dlMainMenu.SelectedIndex = 1
        ElseIf Session.Contents("Create") = "Y" And Session.Contents("Access") = "N" And Session.Contents("Password") = "N" Then
          dlMainMenu.SelectedIndex = 2
        ElseIf Session.Contents("Create") = "N" And Session.Contents("Access") = "Y" And Session.Contents("Password") = "N" Then
          dlMainMenu.SelectedIndex = 2
        ElseIf Session.Contents("Create") = "N" And Session.Contents("Access") = "N" And Session.Contents("Password") = "Y" Then
          dlMainMenu.SelectedIndex = 2
        ElseIf Session.Contents("Create") = "Y" And Session.Contents("Access") = "Y" And Session.Contents("Password") = "N" Then
          dlMainMenu.SelectedIndex = 3
        ElseIf Session.Contents("Create") = "Y" And Session.Contents("Access") = "N" And Session.Contents("Password") = "Y" Then
          dlMainMenu.SelectedIndex = 3
        ElseIf Session.Contents("Create") = "N" And Session.Contents("Access") = "Y" And Session.Contents("Password") = "Y" Then
          dlMainMenu.SelectedIndex = 3
        Else
          dlMainMenu.SelectedIndex = 4
        End If

      End If

    Catch ex As Exception
      Throw ex

    End Try

  End Sub
#End Region
   
  
End Class

Open in new window

0
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 
LVL 96

Expert Comment

by:Bob Learned
ID: 39847938
Do you have the @MasterType directive in the content page?

<%@ MasterType  virtualPath="~/MasterPage.master"%>
0
 

Author Comment

by:EDW_Gideon
ID: 39848014
Here is the head of my MasterPage:

<%@ Master Language="VB" CodeFile="MasterPage.master.vb" Inherits="MasterPage" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>

Open in new window

0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 500 total points
ID: 39848094
On closer inspection, you are showing the MasterPage page, and I think that you have a naming conflict, since the page name and the class name are the same, and the compiler might be getting confused.  You might try to rename the MasterPage.master to something like SiteMaster.master.
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

732 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question