Solved

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

Posted on 2014-02-07
6
560 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
  • 3
  • 2
6 Comments
 
LVL 21

Expert Comment

by:Dale Burrell
Comment Utility
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
Comment Utility
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
Comment Utility
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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 96

Expert Comment

by:Bob Learned
Comment Utility
Do you have the @MasterType directive in the content page?

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

Author Comment

by:EDW_Gideon
Comment Utility
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
Comment Utility
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
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…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

763 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

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now