Sub Site

P

Paul W Smith

I currently have a web site at www.middlesexccl.com

I am also developing a new version of the web site using ASP.NET. I would
like to give certain people access to this for evaluation purposes, so I
thought I would create a directory called NewSite and copy the new files
there. My problem is when I use

www.middlesexccl.com/NewSite/LeagueTables.aspx

I get an error message - Server Error in '/' Application. I have done as
suggested by inserting the line in my webconfig file. The LeagueTables.apsx
file works correctly on my local machine.

If I try to reference an HTML page from the NewSite directory I have no
issue.

Can anyone let me know what my issue is, and how to solve it.

PWS
 
M

Mark Rae [MVP]

Can anyone let me know what my issue is, and how to solve it.

Not without seeing your code. Please show the markup and codebehind for the
page in question...
 
P

Paul W Smith

List of LeagueTables.aspx
(Listing of LeagueTables.aspx.vb after this above listing)

<%@ Page Language="VB" MasterPageFile="~/MasterPage.master"
AutoEventWireup="false" CodeFile="LeagueTables.aspx.vb"
Inherits="LeagueTable" title="Untitled Page" %>

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

<div>
<div class="tabContents">
<asp:Label ID="lblDivName" runat="server"
Text="DivisionName"></asp:Label>
<asp:MultiView ID="mvLeagueTable" ActiveViewIndex="1"
runat="server">

<!-- VIEW 1 -->
<asp:View id="View1" Runat="Server">
<asp:GridView ID="gvLeagueTable" runat="server"
GridLines="None">
</asp:GridView>
<asp:Label ID="lblLeagueTableText" runat="server">
</asp:Label>
</asp:View>

<!-- VIEW 2 -->
<asp:View id="View2" Runat="Server">
<asp:GridView ID="gvResultsGrid" runat="server"
AutoGenerateColumns="False" DataSourceID="AccessDataSource1"
GridLines="None" CssClass="LeagueDivisionText">
<Columns>
<asp:TemplateField ShowHeader="False">
<ItemTemplate>
<table style="border: solid 1px Navy">
<tr>
<td Width="250pt">
Played at
<%#HomeTeamName(Eval("Home1"),Eval("Team1"),Eval("Team2"))%>
</td>
<td Width="200pt">
<%#Eval("MatchResultText")%>
</td>
<td rowspan="3">
<asp:HyperLink ID="HyperLink1"
runat="server"
ImageUrl="~/Images/NewScorebook.GIF"
NavigateUrl='<%#
"Scoresheet.aspx?FixID=" & Eval("FixtureID")%>'>
</asp:HyperLink>
</td>
</tr>
<tr>
<td>
<%#
CricketScore(Eval("Team1"),Eval("Score1"),Eval("Wkts1"),Eval("Dec"),Eval("Overs1"))%>
</td>
<td>
<%#
TeamGamePoints(Eval("Team1"),Eval("Points1"))%>
</td>
</tr>
<tr>
<td>
<%#CricketScore(Eval("Team2"),
Eval("Score2"), Eval("Wkts2"), False, Eval("Overs2"))%>
</td>
<td>
<%#
TeamGamePoints(Eval("Team2"),Eval("Points2"))%>
</td>
</tr>
<tr>
<td style="border-top: navy 1px
solid;" colspan="3">

</td>
</tr>
</table>
</ItemTemplate>
<ItemStyle CssClass="ResultsGrid" />
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:AccessDataSource ID="AccessDataSource1" runat="server"
DataFile="~/App_Data/NewMCCL.mdb"
SelectCommand="SELECT * FROM
[web_MatchReportingByWeekID]">
</asp:AccessDataSource>
</asp:View>
</asp:MultiView>
</div>
<asp:Menu
id="Menu1"
Orientation="Horizontal"
StaticMenuItemStyle-CssClass="tab"
StaticSelectedStyle-CssClass="selectedTab"
CssClass="tabs"
OnMenuItemClick="Menu1_MenuItemClick"
Runat="server">
<Items>
<asp:MenuItem Text="League Table" Value="0" Selected="true" />
<asp:MenuItem Text="Fixtures/Results" Value="1" />
<asp:MenuItem Text="Statistics" Value="2" />
</Items>
</asp:Menu>
</div>

</asp:Content>

'==========================================================================
List of LeagueTables.aspx.vb


Partial Class LeagueTable
Inherits System.Web.UI.Page

Sub Menu1_MenuItemClick(ByVal sender As Object, ByVal e As
MenuEventArgs)
Dim index As Integer = Int32.Parse(e.Item.Value)
mvLeagueTable.ActiveViewIndex = index
End Sub

Function CricketScore(ByVal Team, ByVal Score, ByVal Wkts, ByVal Dec,
ByVal Overs) As String
Dim STeam As String
STeam = Team
Dim sScore As String
sScore = Score
Dim sWkts As String
sWkts = Wkts
Dim sDec As String
If Dec Then
sDec = " Dec"
Else
sDec = ""
End If
Dim sOvers As String
sOvers = " (" & Overs & " overs)"

CricketScore = STeam & " " & sScore & "-" & sWkts & sDec & sOvers
End Function

Function HomeTeamName(ByVal Home1, ByVal Team1, ByVal Team2) As String
Dim bHome1 As Boolean
bHome1 = Home1
If bHome1 Then
HomeTeamName = Team1
Else
HomeTeamName = Team2
End If
End Function

Function TeamGamePoints(ByVal Team, ByVal Points) As String
Dim sTeam As String
sTeam = Team
Dim iPoints As Int16
iPoints = Points
If iPoints = 1 Then
TeamGamePoints = sTeam & " " & iPoints & "pt"
Else
TeamGamePoints = sTeam & " " & iPoints & "pts"
End If
End Function


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

'Establish Connection
Dim sDBPath = "Data Source=D:\MCCL\AccessDB\NewMCCL.mdb;"
Dim sConnString = "Provider=Microsoft.Jet.OLEDB.4.0;" & sDBPath
Dim myConnection As New OleDbConnection(sConnString)

Dim iYearNo As Int32 = 2007

Dim iDivNo As Int16
iDivNo = Request.QueryString("DivNo")
If iDivNo = 0 Then iDivNo = 1

Dim MyCommand1 As New OleDbCommand("", myConnection)
MyCommand1.CommandType = CommandType.StoredProcedure
MyCommand1.CommandText = "web_LeagueTables"
MyCommand1.Parameters.AddWithValue("DivisionID", iDivNo)

Dim myAdapter1 As OleDbDataAdapter = New
OleDbDataAdapter(MyCommand1)

Dim MyCommand2 As New OleDbCommand("", myConnection)
MyCommand2.CommandType = CommandType.StoredProcedure
MyCommand2.CommandText = "web_LeagueTablesComments"
MyCommand2.Parameters.AddWithValue("YearNo", iYearNo)
MyCommand2.Parameters.AddWithValue("DivNo", iDivNo)

Dim myAdapter2 As OleDbDataAdapter = New
OleDbDataAdapter(MyCommand2)

myConnection.Open()

Dim MyDataSet As New DataSet

myAdapter1.Fill(MyDataSet, "LeagueTable")
myAdapter2.Fill(MyDataSet, "Notes")

myConnection.Close()


gvLeagueTable.DataSource = MyDataSet.Tables("LeagueTable")
gvLeagueTable.DataBind()

gvResultsGrid.datasource = MyDataSet.Tables("WeekResults")
gvResultsGrid.DataBind()


Dim bTiedGamesPresent As Boolean
Dim bDrawn3GamesPresent As Boolean
Dim bPenaltyPointsPresent As Boolean

'===Divison Label
lblDivName.CssClass = "DivisionName"
lblDivName.Text = MyDataSet.Tables("LeagueTable").Rows(0)(0)

'===League Table
Dim GridRow As GridViewRow
For Each GridRow In gvLeagueTable.Rows
If Len(GridRow.Cells(3).Text) = 0 Then
bTiedGamesPresent = True
End If
If Len(GridRow.Cells(5).Text) = 0 Then
bDrawn3GamesPresent = True
End If
If Len(GridRow.Cells(9).Text) = 0 Then
bPenaltyPointsPresent = True
End If
Next

gvLeagueTable.HeaderRow.Cells(0).Visible = False
If bTiedGamesPresent = False Then
gvLeagueTable.HeaderRow.Cells(3).Visible = False
End If
If bDrawn3GamesPresent = False Then
gvLeagueTable.HeaderRow.Cells(5).Visible = False
End If
If bPenaltyPointsPresent = False Then
gvLeagueTable.HeaderRow.Cells(9).Visible = False
End If

For Each GridRow In gvLeagueTable.Rows
GridRow.Cells(0).Visible = False
GridRow.Cells(1).HorizontalAlign = HorizontalAlign.Left
If bTiedGamesPresent = False Then
GridRow.Cells(3).Visible = False
End If
If bDrawn3GamesPresent = False Then
GridRow.Cells(5).Visible = False
End If
If bPenaltyPointsPresent = False Then
GridRow.Cells(9).Visible = False
End If
Next

With gvLeagueTable
.CssClass = "TableGrid"
.HeaderRow.Cells(1).Text = ""
.HeaderRow.Cells(1).Width = "120"
.HeaderRow.Cells(2).Text = "Won<br/>10pts"
.HeaderRow.Cells(3).Text = "Tied<br/>5pts"
.HeaderRow.Cells(4).Text = "Drawn<br/>4pts"
.HeaderRow.Cells(5).Text = "Drawn<br/>3pts"
.HeaderRow.Cells(6).Text = "Drawn<br/>1pt"
.HeaderRow.Cells(7).Text = "Aband<br/>1pt"
.HeaderRow.Cells(8).Text = "lost<br/>0pts"
.HeaderRow.Cells(9).Text = "Penalty<br/>points"
.HeaderRow.Cells(10).Text = "Total<br/>points"

.HeaderStyle.CssClass = "LeagueTableTitle"
.RowStyle.CssClass = "LeagueTableBody"
End With

'===League Table Text
lblLeagueTableText.CssClass = "LeagueTableText"
lblLeagueTableText.Text = MyDataSet.Tables("Notes").Rows(0)("Text")

'========================================================================================================


End Sub


End Class
 
P

Paul W Smith

Not previously, but I did after reading your message and it made no
difference. I have no idea what the important or relevance of the sub site
being a virtual directory.

Is it possible to do what I am trying to do, have sub site below the main
site?

I am sure you have read the error message, what does this mean?

I have added the suggested line to my webocnfig file and it seems to make no
difference.

PWS
 
P

Paul W Smith

An even simpler listing that produces the same resule without an code behind
page.

<%@ Page Language="VB" %>

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

<script runat="server">

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
TEST ASP PAGE
</div>
</form>
</body>
</html>
 
J

Juan T. Llibre

re:
!> I have no idea what the important or relevance of the sub site being a virtual directory.

Relative site paths are different when the directory is configured virtually.

You're using a MasterPage, for example.
The path to the MasterPage changes if you use a virtual directory...or not.

You're using an Access db. ( you're using an AccessDataSource... )

How are you determining the path to the Access database ?

Is the .mdb in the App_Data directory ?
If not, are you using a relative or a physical path to point to the mdb ?

re:
!> Is it possible to do what I am trying to do, have sub site below the main site?

Yes. That's quite common.

You could also, simply, configure the site as a virtual directory
below wwwroot, just like your current applicatin is configured.

You don't need to configure the new app as a sub site of your current app.

re:
!> I get an error message - Server Error in '/' Application.
!>I have done as suggested by inserting the line in my webconfig file.

What would help more is posting the error message returned
*after* you changed web.config so the true error is returned.
 
M

Mark Rae [MVP]

Firstly, you don't have any exception handling in your codebehind - that's
the first thing to fix.

Secondly, are you sure about this as it applies to the remote server:
 
P

Paul W Smith

Thank you for the information below, I think I understand it [smile]

It appears that changing to a virtual directory has made some differences
and all that reamins is for me to get my paths correct.

Its seems I was not patient enough after I created the virtual directory.

Thanks for your help.

PWS
 
?

=?ISO-8859-1?Q?G=F6ran_Andersson?=

Paul said:
I currently have a web site at www.middlesexccl.com

I am also developing a new version of the web site using ASP.NET. I would
like to give certain people access to this for evaluation purposes, so I
thought I would create a directory called NewSite and copy the new files
there. My problem is when I use

www.middlesexccl.com/NewSite/LeagueTables.aspx

I get an error message - Server Error in '/' Application. I have done as
suggested by inserting the line in my webconfig file. The LeagueTables.apsx
file works correctly on my local machine.

If I try to reference an HTML page from the NewSite directory I have no
issue.

Can anyone let me know what my issue is, and how to solve it.

PWS

The folder where you put the application has to be configured as an
application in IIS.

A directory or a virtually directory can be configured as an
application, but neither is by default.

In the IIS manager, open the properties for the folder and press the
Create button.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,781
Messages
2,569,615
Members
45,303
Latest member
Ketonara

Latest Threads

Top