Sheldon M. Penner
Sheldon M. Penner

Reputation: 11

VS 2022 Community does not recognize Master Page and other controls

I recently installed Visual Studio 2022 Community and loaded the web site I have been working on. The file text in all my files is covered with squigglies. VS does not recognize most of the objects referenced in my code, starting with the first line of most of my .aspx pages, which is a reference to a Master Page. I get a squiggly under the line '<%@ Page Language="VB" MasterPageFile="Ppm.master" AutoEventWireup="false" ...' and the error message "BC3002 Type 'Web.UI.MasterPage' is not defined." Following is the code on my master page PPM.Master.aspx and PPM.Master.vb. as well as the referencing code in one of my web pages.

PPM.MASTER.ASPX

<%@ Master Language="VB" CodeFile="PPM.master.vb" Inherits="PPM" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>PpmMasterPage</title>
    <link href="PPMStyle.css" rel="stylesheet" type="text/css" />
    <style media="print" type="text/css">
    .noprint {display:none;}
    </style>
    <script src="Scripts/jquery-3.2.1.js" type="text/javascript"></script>
    <script src="Scripts/Ascendor.js" type="text/javascript"></script>
</head>
<body>
       <form id="frm" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true"
     EnablePartialRendering="true" >
    </asp:ScriptManager>


        <table width="100%" border="0">
            <tr valign="top">
                <td colspan="2" style="padding-left: 5px; padding-top: 5px;">
                    <div style="background-color: navy" >
                        <img src="images/donquiotecwc_small.jpg" style="float:left;margin-right:5px; " alt="Ascendor.net"/>
                        <h1 style="color:White; height: 65px; padding-left:50px; padding-top: 60px; margin-bottom:10px; background-color: navy; vertical-align: top; font-family: 'Times New Roman', Times, serif;"><i>Ascendor.net</i></h1>
                    </div>
                    <div id="header-bottom" class="menubar">
                        <span id="tagline">Tools for Getting Things Done</span>
                        <span id="DirectoryLinks" runat="server">
                            <asp:HyperLink ID="lnkDoList" runat="server" NavigateUrl="javascript:DoListToday();">DoList</asp:HyperLink>
                            &nbsp;|&nbsp;<asp:hyperlink ID="lnkRecurring" runat="server" NavigateUrl="~/Recurring.aspx">Recurring Tasks & Events</asp:hyperlink>
                            &nbsp;|&nbsp;<asp:HyperLink ID="lnkCalendarSearch" runat="server" NavigateUrl="~/Search.aspx">Search My Data</asp:HyperLink>
                            &nbsp;|&nbsp;<asp:hyperlink ID="lnkWebSearch" runat="server" NavigateUrl="~/WebSearch.aspx">Search the Web</asp:hyperlink>
                            &nbsp;|&nbsp;<asp:HyperLink ID="lnkHome" runat="server" NavigateUrl="~/default.aspx">Home</asp:HyperLink>
                            &nbsp;|&nbsp;<asp:HyperLink ID="lnkContact" runat="server" NavigateUrl="mailto:[email protected]?subject=Ascendor">Contact Us</asp:HyperLink>
                            &nbsp;&nbsp;
                        </span>
                    </div>
                </td>
            </tr>
            <tr valign="top">
                <td id="divSidebar" valign="top" width="25%">
                    <asp:ContentPlaceHolder ID="cphSideBar" runat="server">
                    </asp:ContentPlaceHolder>
                </td>
                <td id="contents" valign="top" style="padding: 5px">
                    <asp:contentplaceholder id="cphMain" runat="server">
                    </asp:contentplaceholder>
                </td>
            </tr>
        </table>
        <!-- FOLLOWING IFRAME CONTAINS PAGE THAT REFRESHES SESSION AT 10 SECONDS BEFORE 
        SESSION TIMEOUT -->
        <iframe id="defib" src="Defibrillator.aspx" frameborder="0" width="0" height="0"
        runat="server" />
    </form>
</body>
</html>

PPM.MASTER.VB

Imports System
Imports System.Globalization
Imports System.Threading

Partial Class PPM
    Inherits System.Web.UI.MasterPage

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not IsPostBack Then

            If Session("OwnerID") Is Nothing Then
                'DirectoryLinks.Disabled = True
                Dim c As Control
                For Each c In DirectoryLinks.Controls
                    If TypeOf c Is HyperLink And c.ID <> "lnkContact" Then
                        CType(c, HyperLink).Enabled = False
                    End If
                Next
            Else

                'Disable menu link to current page
                Dim url As String = LCase(Request.RawUrl.ToString)
                If url Like "*/recurring.aspx*" Then
                    Me.lnkRecurring.Enabled = False
                ElseIf url Like "*/default.aspx" Then
                    Me.lnkHome.Enabled = False
                ElseIf url Like "*/search.aspx*" Then
                    Me.lnkCalendarSearch.Enabled = False
                ElseIf url Like "*/websearch.aspx*" Then
                    Me.lnkWebSearch.Enabled = False
                ElseIf url Like "*/dolistoutline.aspx*" Then
                    'Change text, enable refresh
                    lnkDoList.Text = "Refresh DoList"
                End If

            End If

            'If TaskID or ProjectID was passed to this page in querystring, 
            'pass it along to WebSearch
            If Request.QueryString("TaskID") > 0 Then
                Me.lnkWebSearch.NavigateUrl = "~/WebSearch.aspx?TaskID=" & Request.QueryString("TaskID").ToString
            ElseIf Request.QueryString("ProjectID") > 0 Then
                Me.lnkWebSearch.NavigateUrl = "~/WebSearch.aspx?TaskID=" & Request.QueryString("ProjectID").ToString
            End If

            'Set variable to convert dates to USA format
            If Application("usaCulture") Is Nothing Then
                Application.Lock()
                Application("usaCulture") = New CultureInfo("en-US")
                Application.UnLock()

            End If
        End If
    End Sub

End Class

SIGNIN.ASPX

<%@ Page Language="VB" MasterPageFile="Ppm.master" AutoEventWireup="false" CodeFile="SignIn.aspx.vb" Inherits="SignIn" title="Sign In" %>

<asp:Content ID="Content1" ContentPlaceHolderID="cphMain" Runat="Server">

    <table align="left">
        <tr>
            <td style="width: 100px">
                &nbsp;</td>
            <td style="width: 100px">
            </td>
            <td style="width: 100px">
            </td>
        </tr>
        <tr>
            <td style="width: 100px">
                <img src="images/sitemapSignIn.gif" alt="Sign In" /></td>
            <td valign="top">
                <table align="left">
                    <tr>
                        <td nowrap="nowrap">
                            <asp:HiddenField ID="hidToday" runat="server" Visible="true" />
                        </td>
                        <td nowrap="noWrap">
                            MEMBER LOGIN</td>
                        <td nowrap="nowrap">
                        </td>
                    </tr>
                    <tr>
                        <td>
                        </td>
                        <td>
                            &nbsp;</td>
                        <td>
                        </td>
                    </tr>
                    <tr>
                        <td nowrap="nowrap">
                        </td>
                        <td nowrap="nowrap">
                            <asp:Label ID="lblMsg" runat="server" ForeColor="Red"></asp:Label></td>
                        <td nowrap="nowrap">
                        </td>
                    </tr>
                    <tr>
                        <td>
                        </td>
                        <td>
                            &nbsp;</td>
                        <td>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            User Name:</td>
                        <td>
                            <asp:TextBox ID="txtUserName" runat="server" ></asp:TextBox>
                        </td>
                        <td>
                            <asp:RequiredFieldValidator ID="rfvUserName" runat="server" ControlToValidate="txtUserName"
                                ErrorMessage="<img src=&quot;images/warn.gif&quot; title=&quot;Please Enter UserName!&quot; alt=&quot;*&quot; align=&quot;absmiddle&quot; style=&quot;cursor: hand&quot; onclick=&quot;alert('Please Enter UserName!!')&quot;>"></asp:RequiredFieldValidator></td>
                    </tr>
                    <tr>
                        <td>
                            Password:</td>
                        <td>
                            <asp:TextBox ID="txtPassword" runat="server" TextMode="Password" CssClass="text"></asp:TextBox>
                            </td>
                        <td>
                            <asp:RequiredFieldValidator ID="rfvPassword" runat="server" ControlToValidate="txtPassword"
                                ErrorMessage="<img src=&quot;images/warn.gif&quot; title=&quot;Please enter Password&quot; alt=&quot;*&quot; align=&quot;absmiddle&quot; style=&quot;cursor: hand&quot; onclick=&quot;alert('Please Enter Password!')&quot;>"></asp:RequiredFieldValidator></td>
                    </tr>
                    <tr>
                        <td>
                        </td>
                        <td>
                        </td>
                    </tr>
                    <tr>
                        <td>
                        </td>
                        <td>
                            &nbsp;<asp:CheckBox ID="chkRemember" runat="server" Text="Remember Me" Font-Size="XX-Small" /></td>
                        <td>
                        </td>
                    </tr>
                    <tr>
                        <td>
                        </td>
                        <td>
                            <asp:Button ID="btnSignIn" runat="server" Text="Sign In" Width="80px" /></td>
                        <td>
                        </td>
                    </tr>
                </table>
            </td>
            <td valign="top">
            </td>
        </tr>
    </table>
    
    <script type="text/javascript" language="javascript">
        window.onload = function () {
            var dt = document.getElementById('<%= hidToday.ClientID %>');
            dt.value = ClientDate();

            if (getCookie('myPPM') != null) {
                document.getElementById('<%= btnSignIn.ClientID %>').click();
            }
        }

        function getCookie(name) {
            var regexp = new RegExp("(?:^" + name + "|;\s*" + name + ")=(.*?)(?:;|$)", "g");
            var result = regexp.exec(document.cookie);
            return (result === null) ? null : result[1];
        }
    </script>
</asp:Content>


I would like to continue debugging and revising this app, as I had been doing prior to installing VS 2022. How can I reconcile my app with this newer version of Visual Studio Community?

Upvotes: 0

Views: 179

Answers (1)

Albert D. Kallal
Albert D. Kallal

Reputation: 49264

I am currentnly using vs2022, and am able to freely open and work on asp.net webform projects, even ones that are 15 years old, and they work perfect in vs2022.

So, as a quick test (less then 1 minute of your time), I would try creating a new webforms project, and see if that project works. If that project does not work, then of course you are wasting your time trying to edit and with with previous projects.

So, try creating a new project, this choice:

enter image description here

So, when you create a new webforms project, does it load and run ok?

It stands to reason if you can't create and work on a new project you create, then trying to work on existing projects also will not work.

So, before you try creating the project (or opening a previous one), then make sure all the webforms tools are installed. The webforms workflows are not installed by default in vs2022.

Hence, launch vs2022, from menu -> tools -> get tools and features.

And ensure all of these options are selected:

enter image description here

And then on the right side, select these:

enter image description here

Note how I even selected the RDLC Report Designer, since your project may well have some reports.

After you install the above workflows, then you should freely be able to open previous projects and work on them. And you also now see the additonal project types when creating a new project.

I should also point out by default, vs2022 defaults to a new web forms "live preview" designer. While that new "live preview" is great, renders the webform with a new chrome engine?

It does not correctly support drag + drop from the tool box, and hence before opening (or creating) a webforms project, I recommend you change the default web forms preview and designer back to the legacy one.

Hence, tools->options->Web Forms Designer

enter image description here

So, change back to the Legacy Web Forms designer.

After installing the above workflows, then I am able to freely open and work on previous projects (assuming they opened and work fine with previous versions of Visual Studio).

Upvotes: 0

Related Questions