ASP Net Parser Error - asp.net

Line 1: <%# Page Language="vb" AutoEventWireup="false" CodeBehind="Berechtigungen.aspx.vb" Inherits="Berechtigungen.Berechtigungen" %>
My ASPX Page: Berechtigungen.aspx & Berechtigungen.aspx.vb
The .aspx.vb file:
<Serializable()>
Public Class Berechtigungen
Why is my Inherit not working?

Related

files name in asp.net and vb.net

I have .aspx and .vb files. The name of it are: SA_Setup.aspx and SA_Setup.vb.
The 1st 10 lines of the code in SA_Setup.aspx file is:
<%# Page Title="" Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false"
CodeFile="SA_Setup.aspx.vb" Inherits="SA_Setup" %>
<%# Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<%# MasterType VirtualPath="~/MasterPage.master" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
<link id="Link2" rel="Stylesheet" href="~/Common/OrgSelfAssessment.css" type="text/css"
media="screen" runat="server" />
</asp:Content>
And the 1st 10 lines of code in SA_Setup.aspx.vb file is:
Imports System.Data
Imports GlobalModule
Partial Class SA_Setup
Inherits System.Web.UI.Page
Dim dalGM As GlobalModule
Dim dalSelfAssessment As New SelfAssessmentSetUp
Dim dalSurveyAdmin As New SurveyAdmin
Dim dalClientAdmin As New ClientAdmin
Protected Overrides Sub InitializeCulture()
Try
Dim strCul As String : strCul = Session("Culture")
System.Threading.Thread.CurrentThread.CurrentUICulture = New System.Globalization.CultureInfo(strCul)
System.Threading.Thread.CurrentThread.CurrentCulture = New System.Globalization.CultureInfo(strCul)
Catch ex As Exception
Response.Redirect("~/Error/ErrorPage.aspx?type=SessionTimedOut&ui=" & Request.QueryString("ui"), True) : Exit Sub
End Try
End Sub
Now, I have changed the files name to SA_Setup_MPHLB.aspx and SA_Setup_MPHLB.aspx.vb. I am wondering what changes do I need to do in the codes above after changing the files name. As per my understanding, I have made the following changes:
In .aspx file (SA_Setup_MPHLB.aspx):
<%# Page Title="" Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false"
CodeFile="SA_Setup_MPHLB.aspx.vb" Inherits="SA_Setup_MPHLB" %>
In .aspx.vb file (SA_Setup_MPHLB.aspx.vb):
Partial Class SA_Setup_MPHLB
Just checking if the changes I have did is right or is there any place I have to do the changes ?
If you are able to successfully rebuild the project after name changes, you may not need to do anything else. If you are getting any error, it will surely suggest you what to do next.

Parser Error in Namespace?

I have a webpage that was built using the All In One style (the VB in the page with the HTML), and I have been asked to separate them.
This is how Default.aspx starts out:
<%# Import Namespace="System.Net" %>
<%# Import Namespace="System.IO" %>
<%# Import Namespace="System.Configuration" %>
<%# Import Namespace="System.Data" %>
<%# Import Namespace="System.Data.OleDb" %>
<%# Import Namespace="System.Data.SqlClient" %>
<%# Import Namespace="System.Globalization" %>
<%# Import Namespace="System.Security" %>
<html>
<head>
<title>View an Activity (AFE)</title>
<script language="VB" runat="server">
Private m_url1, m_url2, m_downloadText, txtSupplementPage, txtExcerpt, SearchLocation, SearchLocation2, SearchLocation3, SearchLocationOrig As String
Private myTotal1, myTotal2 As Double
Private m_credentials As CredentialCache
' Start the initial page
Protected Sub Page_Load(sender As Object, e As EventArgs)
m_credentials = New CredentialCache()
If Not IsPostBack Then
It goes on. This is just to show you what I'm doing.
I created a new, similar file called that Default2.aspx that includes the Page directive, specifies the CodeBehind file, and the namespace (Inherits). Then I took the VB code out:
<%# Page Language="vb" AutoEventWireup="true" CodeBehind="Default.aspx.vb" Inherits="app2._Default" %>
<!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 runat="server">
<title>View an Activity (AFE)</title>
Since Default.aspx did not use a Code Behind file, I named my new Code Behind file Default.aspx.vb.
I created a new _Default with Namespace app2 within this Code Behind file, and I copied all of the VB from Default.aspx into it:
Namespace app2
Public Class _Default
Inherits System.Web.UI.Page
Inherits System.Net
Inherits System.IO
Inherits System.Configuration
Inherits System.Data
Inherits System.Data.OleDb
Inherits System.Data.SqlClient
Inherits System.Globalization
Inherits System.Security
Private m_url1, m_url2, m_downloadText, txtSupplementPage, txtExcerpt, SearchLocation, SearchLocation2, SearchLocation3, SearchLocationOrig As String
Private myTotal1, myTotal2 As Double
Private m_credentials As CredentialCache
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
m_credentials = New CredentialCache()
If Not IsPostBack Then
I am trying to give enough code that everyone can see the starting points and where I am now.
I got the two new files uploaded to the web server, and then browsed to them to see how they would look.
However, now when I try to display Default2.aspx in the browser, I get this Parser Error:
Parser Error Message: Could not load type 'app2._Default'.
Source Error:
Line 1: <%# Page Language="vb" AutoEventWireup="true" CodeBehind="Default.aspx.vb" Inherits="app2._Default" %>
Line 2:
Line 3:
What have I messed up?
For a web site: Change CodeBehind to CodeFile.
<%# Page Language="vb" AutoEventWireup="true" CodeFile="Default.aspx.vb" Inherits="app2._Default" %>
For a web application: Add the name of the web project to the Inherits attribute.
<%# Page Language="vb" AutoEventWireup="true" CodeBehind="Default.aspx.vb" Inherits="nameOfYourWebProject.app2._Default" %>
Also, the _Default class you provided, you can only have one Inherits, I think you meant to add them as Imports on the top of the page.

ASP.NET page inheritance: Controls from base class are not initialized

I am using a base page and an inherited page. The base page is working fine.
In the inherited page I have the following #Page-directive:
<%# Page Title="" Language="C#" AutoEventWireup="True" Inherits="SubPage" CodeFileBaseClass="BasePage" CodeFile="SubPage.aspx.cs" %>
and the following code-behind file
public partial class SubPage: BasePage
The problem is that in Page_Load of the base class, all Controls are null.
A master-page is no solution for me in this case.
Inhert your code-behind as you would normally using:
public partial class SubPage: BasePage
and in markup do something like:
<% # Page Language="C#" MasterPageFile="~/Master.master" Title="SubPage" %>
<asp:Content ID="Content1" ContentPlaceHolderID="Main" Runat="Server">
Main content.
</asp:Content>
http://msdn.microsoft.com/en-us/library/vstudio/wtxbf3hh(v=vs.100).aspx
EDIT:
If masterpage is not what you want you'll have to do:
<%# Page Title="" Language="C#" AutoEventWireup="True" Inherits="BasePage" CodeFileBaseClass="BasePage" CodeFile="SubPage.aspx.cs" %>
and copy whole markup of BasePage below. Code-Behind is inherited same way again:
public partial class SubPage: BasePage

Namespace in Code Behinde and ASP.Net

i designed web page and put controls in it , then i added name space to code behind file and add
<%# Page Language="C#" AutoEventWireup="true" MasterPageFile="~/Site.master" CodeFile="Default.aspx.cs"
Inherits="_Default" %>
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>
<%# Import Namespace="RegisterName" %>
to asp file and
namespace RegisterName
{
public partial class _Default : System.Web.UI.Page
{
now i have some Error :
Error 4 'ASP.default_aspx' does not implement interface member 'System.Web.IHttpHandler.IsReusable'
You need both the page and the code-behind to be parts of the same namespace.
By adding the namespace declaration to the code-behind, it and the web page are now in different namespaces.
Additionally, the #Import page directive simply means that you can access types declared in the imported namespace, not that the page belongs to it.
You need to ensure that the #Page directive matches the fully qualified name of the code-behind class.

Access in page an object from MasterPage that inherits from another MasterPage

I have the following hierarchy:
Site.Master
Site2.Master
Page1.aspx
Page2.aspx
Page3.aspx
Page4.aspx
On Page3 and Page4 I can access an object on Site.Master using <%# MasterType VirtualPath="~/Site.Master" %> on aspx file.
How can I access same object on Page1 and Page2?
I tried:
1) Put <%# MasterType VirtualPath="~/Site.Master" %> on Page1.aspx but I receive an error.
2) Put <%# MasterType VirtualPath="~/Site.Master" %> on Site2.Master and <%# MasterType VirtualPath="~/Site2.Master" %> on Page1.aspx. Page1.aspx open but I can't access object using Master property.
Thank you.
public Site TopMasterPage
{
get
{
return (this.Master as Site) ?? this.Master.Master as Site;
}
}

Resources