Solved

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

Posted on 2014-02-07
6
606 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
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
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 
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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
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…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

740 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