Add Page to project - Difficult

I have a project that on build compiles all the "code-behind" vb pages into a project DLL

If I ADD>Item>WebForm...no problem.

However...
If I try and build a page programatically with the following code I get the very same "looking" page

But the Namespace doesn't seem to get recognized.

The page builds
I can then "Include In Project"
But it fails on build.

If I change the Inherits="Nightingale.(class)"
to Inherits="(class") no error...but now I have to include the vb code behind page in my deployment.

Heres the build page code

 Public Sub BuildAspx(ByVal _t As String)
        _page = _t
        Dim writer As New XmlTextWriter(Server.MapPath("" & _page & ".aspx"), Encoding.UTF8)
        writer.WriteRaw("<%@ Page language=""VB"" MasterPageFile=""~/NgMaster.Master"" AutoEventWireup=""false"" CodeFile=""" & _page & ".aspx.vb"" Inherits=""NightingaleMan." & _page & """ %>")
        writer.WriteRaw(Environment.NewLine)
        writer.WriteRaw(Environment.NewLine)
        writer.WriteRaw("<%@ Register Assembly=""Telerik.Web.UI"" Namespace=""Telerik.Web.UI"" TagPrefix=""telerik"" %>")
        writer.WriteRaw(Environment.NewLine)
        writer.WriteRaw(Environment.NewLine)
        writer.WriteRaw("<asp:Content ID=""Content1"" ContentPlaceHolderID=""ContentPlaceHolder1"" runat=""Server"">")
        writer.WriteRaw(Environment.NewLine)
        writer.WriteRaw("     <div class=""hdTitleBar"" style=""width: 99.9%; padding-left: 10px; text-align:left;"">")
        writer.WriteRaw(Environment.NewLine)
        writer.WriteRaw("          Page Title")
        writer.WriteRaw(Environment.NewLine)
        writer.WriteRaw("     </div>")
        writer.WriteRaw(Environment.NewLine)
        writer.WriteRaw("     <div style=""width:100%;"">")
        writer.WriteRaw(Environment.NewLine)
        writer.WriteRaw("         <table cellpadding=""0"" cellspacing=""0"" border=""0"" style=""width: 100%;"">")
        writer.WriteRaw(Environment.NewLine)
        writer.WriteRaw("           <tr>")
        writer.WriteRaw(Environment.NewLine)
        writer.WriteRaw("              <td style=""width: 100%;"">")
        writer.WriteRaw(Environment.NewLine)
        writer.WriteRaw("                   <table cellpadding=""0"" cellspacing=""0"" border=""0"" class=""createTable1"">")
        writer.WriteRaw(Environment.NewLine)
        writer.WriteRaw("                     <tr class=""createTR1"">")
        writer.WriteRaw(Environment.NewLine)
        writer.WriteRaw("                        <td class=""createH14"">")
        writer.WriteRaw(Environment.NewLine)
        writer.WriteRaw("                           <asp:Label id =""lblTitle"" runat=""server"" CssClass=""createLBL620""></asp:Label>")
        writer.WriteRaw(Environment.NewLine)
        writer.WriteRaw("                        </td>")
        writer.WriteRaw(Environment.NewLine)
        writer.WriteRaw("                        <td class=""createPad0808"">")
        writer.WriteRaw(Environment.NewLine)
        writer.WriteRaw("                           &nbsp;")
        writer.WriteRaw(Environment.NewLine)
        writer.WriteRaw("                        </td>")
        writer.WriteRaw(Environment.NewLine)
        writer.WriteRaw("                     </tr>")
        writer.WriteRaw(Environment.NewLine)
        writer.WriteRaw("                   </table>")
        writer.WriteRaw(Environment.NewLine)
        writer.WriteRaw("              </td>")
        writer.WriteRaw(Environment.NewLine)
        writer.WriteRaw("           </tr>")
        writer.WriteRaw(Environment.NewLine)
        writer.WriteRaw("         </table>")
        writer.WriteRaw(Environment.NewLine)
        writer.WriteRaw("     </div>")
        writer.WriteRaw(Environment.NewLine)
        writer.WriteRaw("     <div style=""width:100%;height:600px;"">")
        writer.WriteRaw(Environment.NewLine)
        writer.WriteRaw("          <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<img src=""Images/icon03.png"" alt="""" />New Page Under Construction")
        writer.WriteRaw(Environment.NewLine)
        writer.WriteRaw("     </div>")
        writer.WriteRaw(Environment.NewLine)
        writer.WriteRaw("</asp:Content>")
        writer.Close()
    End Sub

    Public Sub BuildAspxVB(ByVal _t As String, ByVal _p As String)
        _page = _t
        Dim writer As New XmlTextWriter(Server.MapPath("" & _page & ".aspx.vb"), Encoding.UTF8)
        writer.WriteRaw("Imports System")
        writer.WriteRaw(Environment.NewLine)
        writer.WriteRaw("Imports System.Data")
        writer.WriteRaw(Environment.NewLine)
        writer.WriteRaw("Imports System.Data.SqlClient")
        writer.WriteRaw(Environment.NewLine)
        writer.WriteRaw("Imports Telerik.Web.UI")
        writer.WriteRaw(Environment.NewLine)
        writer.WriteRaw("Imports System.Drawing.Color")
        writer.WriteRaw(Environment.NewLine)
        writer.WriteRaw(Environment.NewLine)
        writer.WriteRaw("Partial Class " & _page & "")
        writer.WriteRaw(Environment.NewLine)
        writer.WriteRaw("Inherits System.Web.UI.Page")
        writer.WriteRaw(Environment.NewLine)
        writer.WriteRaw(Environment.NewLine)
        writer.WriteRaw("Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load")
        writer.WriteRaw(Environment.NewLine)
        writer.WriteRaw("     If Session(""logged"") = ""1"" Then")
        writer.WriteRaw(Environment.NewLine)
        writer.WriteRaw("       Session(""page"") = """ & _p.ToString() & """")
        writer.WriteRaw(Environment.NewLine)
        writer.WriteRaw("     Else")
        writer.WriteRaw(Environment.NewLine)
        writer.WriteRaw("          Response.Redirect(""~/Home.aspx"")")
        writer.WriteRaw(Environment.NewLine)
        writer.WriteRaw("     End If")
        writer.WriteRaw(Environment.NewLine)
        writer.WriteRaw("End Sub")
        writer.WriteRaw(Environment.NewLine)
        writer.WriteRaw("End Class")
        writer.Close()
    End Sub

Open in new window

Larry Bristersr. DeveloperAsked:
Who is Participating?
 
CodeCruiserCommented:
You are dynamically creating this page? Off course you have to keep the vb file because its not part of the original DLL file.
0
 
Larry Bristersr. DeveloperAuthor Commented:
CodeCruiser,
  I built this interface so that as I add menu items to my RadPanelBar, I create the page that goes with it.

It's an Admin useage only...just to keep me from manually needing to add the page.

So maybe it would be better to add the page normally, then in my interface, have a dropdown of available pages in the directory and set the panelbar.navigateUrl to that?
0
 
CodeCruiserCommented:
Yeah or keep uploading .vb files.
0
 
Larry Bristersr. DeveloperAuthor Commented:
As always....thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.