 |
BOOK: Beginning ASP.NET 4.5.1 : in C# and VB
 | This is the forum to discuss the Wrox book Beginning ASP.NET 4.5.1: in C# and VB by Imar Spaanjaars; ISBN: 978-1-118-84677-3 |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the BOOK: Beginning ASP.NET 4.5.1 : in C# and VB section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

September 9th, 2015, 08:38 PM
|
Registered User
|
|
Join Date: Sep 2015
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Problem with basepage and template
I have created a base page and the associated template, when sending to ie I get the following VS errors:
1. $relurlnamespace&_&safeitemname$ is not a valid value for attribute 'inherits'
2. Character is not valid
Here are the contents of the basepage. vb and temporary.aspx. vb:
------------------------------------------------------
basepage. vb
Imports Microsoft.VisualBasic
Public Class BasePage
Inherits System.Web.UI.Page
Private Sub Page_PreRender(sender As Object, e As EventArgs) Handles Me.PreRender
If String.IsNullOrEmpty(Me.Title) OrElse Me.Title.Equals("Untitled Page",
StringComparison.CurrentCultureIgnoreCase) Then
Throw New Exception(
"Page title cannot be ""Untitled Page"" or an empty string.")
End If
End Sub
End Class
----------------------------------------------
temporary.aspx. vb
Partial Class $relurlnamespace$_$safeitemname$
Inherits BasePage
End Class
I noticed that in the temporary.aspx. vb file the leading $ shows character not valid.
Thank you for your assistance.
JIm
|

September 10th, 2015, 03:18 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Hi Jim,
The Temporary.aspx page is just that: temporary. It won't run as-is but it serves only to be exported as a template as described in the book (looks like you missed, or haven't carried out this step). Once you've exported the template you can create new pages using this template using the Add New Item dialog.
Hope this helps,
Imar
|

May 1st, 2019, 03:06 PM
|
Registered User
|
|
Join Date: May 2018
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
$relurlnamespace$_$safeitemname$
I am also a newbie and I am seeing the same problem when I rename the class from Temporary to $relurlnamespace$_$safeitemname$.
In case I read something wrong, I opened the file downloaded from the WROX website and Visual Studio shows the red squiggle under the above text in that file as well. This is AFTER I did all of the steps.
When I viewed the source of the TestPage on my website, instead of the title showing as
_TestPage
it showed as
$relurlnamespace$_TestPage
I don't know if that helps you figure out what was wrong or not.
|

May 3rd, 2019, 06:48 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
This is by design. $relurlnamespace$_$safeitemname$ is not a valid identifier in C# so the temporary page is just that: temporary. It serves purely to create a template out of it. Once the template has been created you should delete the Temporary.aspx page again.
When you add a new web form based on the template, Visual Studio will replace $relurlnamespace$_$safeitemname$. with the new, safe, name of the page you're adding.
Does that help?
Imar
|

May 3rd, 2019, 08:48 AM
|
Registered User
|
|
Join Date: May 2018
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I am still getting an error using the beginning "global" symbol (the first text enclosed in dollar signs). And unfortunately, later exercises build on the basepage, so I have to develop a workaround.
|

May 3rd, 2019, 09:45 AM
|
Registered User
|
|
Join Date: May 2018
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
$relurlnamespace$_$safeitemname$
Quote:
Originally Posted by dkeller
I am still getting an error using the beginning "global" symbol (the first text enclosed in dollar signs). And unfortunately, later exercises build on the basepage, so I have to develop a workaround.
When I use the basepage, the first symbol in the dollar signs appears as I have it in the template. The compiler does not substitute. I also noticed in the post on your website that the person who gave you the fix mentioned that it may not work for others without the same advanced settings.
|
I must be doing something wrong because I have an error that my message is too short...
|

May 4th, 2019, 07:32 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Can you be a bit more specific about where you get the error exactly? On which page(s) do you get the error? Maybe you can post a screenshot somewhere showing Visual Studio with the page and offending code?
Also, make sure you created the custom template correct;y. To verify, locate it under your Documents (it's a zip somewhere in the Visual Studio folder) and look at the files in the archive. Do they contain what is needed? Posting the code from those template files would also help.
Cheers,
Imar
|

May 6th, 2019, 03:20 PM
|
Registered User
|
|
Join Date: May 2018
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
When I use the template to create a new webpage (I called it TesterPage.aspx), it looks like this:
<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPages/Frontend.Master" AutoEventWireup="true" CodeBehind="TesterPage.aspx.cs" Inherits="$relurlnamespace$_TesterPage" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="cpMainContent" runat="server">
<p>
</p>
</asp:Content>
You can see in the Inherits attribute that Visual Studio has
Inherits="$relurlnamespace$_TesterPage"
which then gives me further errors.
Is there a setting that I am missing? I copied the code for the base page out of the source files, so there shouldn't be a typo causing the problem.
The Temporary file I used to create the template contains the following code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace dkwebapp1
{
public partial class $relurlnamespace$_$safeitemname$ : BasePage
{
protected void Page_Load(object sender, EventArgs e)
{
}
}
}
(I changed my project name to dkwebapp1 as this is my second time trying to use this book...)
Please shed some light on what it is that I have done wrong! Thanks!
|

May 6th, 2019, 03:35 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
And how does the markup of the template look? You showed an error with the markup, but posted the code for the code behind. Maybe there's something wrong in the markup of the template?
|

May 6th, 2019, 06:00 PM
|
Registered User
|
|
Join Date: May 2018
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Here is the template:
template.aspx
<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPages/Frontend.Master" AutoEventWireup="true" CodeBehind="Template.aspx.cs" Inherits="$relurlnamespace$_$safeitemname$" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="cpMainContent" runat="server">
</asp:Content>
Code behind, Template.aspx.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace dkwebapp1
{
public partial class $relurlnamespace$_$safeitemname$ : BasePage
{
protected void Page_Load(object sender, EventArgs e)
{
}
}
}
Once I created the "Template" template, I closed and re-opened VS, then added a page called, "NewPage.aspx":
<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPages/Frontend.Master" AutoEventWireup="true" CodeBehind="NewPage.aspx.cs" Inherits="$relurlnamespace$_NewPage" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="cpMainContent" runat="server">
</asp:Content>
and its code behind file contains the following:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace dkwebapp1
{
public partial class $relurlnamespace$_NewPage : BasePage
{
protected void Page_Load(object sender, EventArgs e)
{
}
}
}
From what I can see, the first template parameter, $relurlnamespace$ has not been replaced with any valid text, and therefore, I get many errors when I try to open it in a browser. First CS1001, Identifier expected, then CS1514, { expected, then CS1513, } expected, then CS1056, Unexpected character '$', then CS0116 A namespace annot directly ontain members such as fields or methods.....
Does this give you enough info to help me? (I hope so! - I am very frustrated!!)
Here is the MyTEmplate.vstemplate file from the Zip file too:
<VSTemplate Version="3.0.0" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005" Type="Item">
<TemplateData>
<DefaultName>Template.aspx</DefaultName>
<Name>Template</Name>
<Description>Trying to figure out issue</Description>
<ProjectType>CSharp</ProjectType>
<SortOrder>10</SortOrder>
<Icon>__TemplateIcon.ico</Icon>
</TemplateData>
<TemplateContent>
<References />
<ProjectItem SubType="" TargetFileName="$fileinputname$.aspx" ReplaceParameters="true">Template.aspx</ProjectItem>
<ProjectItem SubType="Code" TargetFileName="$fileinputname$.aspx.cs" ReplaceParameters="true">Template.aspx.cs</ProjectItem>
<ProjectItem SubType="" TargetFileName="$fileinputname$.aspx.designer.cs" ReplaceParameters="true">Template.aspx.designer.cs </ProjectItem>
</TemplateContent>
</VSTemplate>
Thank you for your help!
|
Similar Threads
|
Thread |
Thread Starter |
Forum |
Replies |
Last Post |
Chapter 6 BasePage |
Darkryder007 |
BOOK: Beginning ASP.NET 4.5 : in C# and VB |
8 |
April 4th, 2015 04:04 AM |
Chapter 6 BasePage & Template Try It Out |
PhilC |
BOOK: Beginning ASP.NET 4 : in C# and VB |
7 |
April 4th, 2013 02:54 PM |
Basepage |
Khalil |
BOOK: Beginning ASP.NET 4 : in C# and VB |
3 |
December 7th, 2011 06:42 AM |
BasePage Question |
Rushino |
BOOK: Beginning ASP.NET 4 : in C# and VB |
9 |
April 9th, 2010 12:48 PM |
Reference to BasePage |
member4953 |
BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 |
3 |
March 27th, 2009 01:45 PM |
|
 |
|