首页上一页 1 下一页尾页 3 条记录 1/1页
ASP.NET从入门到精通31章无法打开首页
发表在ASP.NET图书答疑
2013-02-20
是否精华
是
否
版块置顶:
是
否
设置时间:
非永久
永久
起始时间:
结束时间:
是否扣分:
是
否
每次打开Default.aspx都会跳到error.aspx,这是咋回事啊?望指教,谢谢!
精彩评论 3
2013-02-27
板凳
据查是:userControl文件夹下navigate.ascx出现在错误。我在母版页把这个引用删除后,Default.aspx页面就能正常运行了。我现在把这个页面的代码拷贝下来,你们高手看看是那里出错了:<%@ Control Language="C#" AutoEventWireup="true" CodeFile="navigate.ascx.cs" Inherits="userControl_navigate" %>
<table style="width: 204px; height:448px; font-size: 9pt; font-family: 宋体; vertical-align :top ; background-image: url(images/商品分类.jpg); background-repeat :no-repeat" border="0" cellpadding="0" cellspacing="0" >
<tr>
<td style="height: 35px">
</td>
</tr>
<tr align =center style="width: 204px; font-size: 9pt; font-family: 宋体; vertical-align :top ;">
<td>
<asp:DataList ID="dlClass" runat="server" OnItemCommand="dlClass_ItemCommand">
<ItemTemplate>
<table >
<tr>
<td align =left style ="width :28px; height :25px;vertical-align :bottom">
<asp:Image ID="imageIcon" runat="server" ImageUrl =<%#DataBinder.Eval(Container.DataItem,"CategoryUrl")%> />
</td>
<td> </td>
<td align =left style ="width :80px; height :25px; font-size: 9pt; font-family: 宋体; vertical-align :bottom " >
<asp:LinkButton ID="lnkbtnClass" runat="server" CommandName="select" CausesValidation="False" CommandArgument =<%#DataBinder.Eval(Container.DataItem,"ClassID") %>><%# DataBinder.Eval(Container.DataItem, "ClassName") %></asp:LinkButton>
</td>
</tr>
</table>
</ItemTemplate>
</asp:DataList>
</td>
</tr>
</table>
<table style="width: 204px; height: 181px; font-size: 9pt; font-family: 宋体; vertical-align :top ; text-align :center; background-image: url(images/新品上市.jpg); background-repeat :no-repeat" border="0" cellpadding="0" cellspacing="0">
<tr>
<td style="height: 31px; width: 204px;"></td>
</tr>
<tr>
<td style="width: 204px;">
<marquee direction="up" onmouseout="this.start()" onmouseover="this.stop()" scrollAmount="2" scrollDelay="7" style="width: 204px;height: 120px; font-size: 9pt; font-family: 宋体; vertical-align :top ; text-align :center; " >
<asp:DataList ID="dlNewGoods" runat="server" OnItemCommand="dlNewGoods_ItemCommand" >
<ItemTemplate>
<table border="0" cellspacing="0" style="font-size :9pt" align =center >
<tr>
<td align="center" colspan="1" rowspan="5">
<asp:ImageButton ID="ImageButton1" runat="server" CommandArgument='<%#DataBinder.Eval(Container.DataItem, "BookID")%>' CommandName="detailSee" ImageUrl='<%#DataBinder.Eval(Container.DataItem,"BookUrl") %>' /></td>
<td colspan="2" align="center">
</td>
</tr>
<tr>
<td align =left style="width: 51px; " >
类别名:
</td>
<td align =left style=" color:#D57421 " >
<%#GetClassName(Convert.ToInt32(DataBinder.Eval(Container.DataItem , "ClassID")))%>
</td>
</tr>
<tr>
<td align =left style="width: 51px">
书 名:
</td>
<td align =left>
<%#DataBinder.Eval(Container.DataItem, "BookName")%>
</td>
</tr>
<tr>
<td align =left style="width: 51px">
作 者:
</td>
<td align =left>
<%#DataBinder.Eval(Container.DataItem,"Author") %>
</td>
</tr>
<tr>
<td align =left style="width: 51px">
出版社:
</td>
<td align =left>
<%#DataBinder.Eval(Container.DataItem,"Company") %>
</td>
</tr>
</table>
</ItemTemplate>
<HeaderStyle Font-Bold="False" Font-Italic="False" Font-Overline="False" Font-Strikeout="False"
Font-Underline="False" ForeColor="Blue" HorizontalAlign="Center" />
</asp:DataList></marquee>
</td>
</tr>
</table>
下面是navigate.ascx.cs页面的代码:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class userControl_navigate : System.Web.UI.UserControl
{
GoodsClass gcObj = new GoodsClass();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
gcObj.DLClassBind(this.dlClass);
gcObj.DLNewGoods(this.dlNewGoods);
}
}
protected void dlClass_ItemCommand(object source, DataListCommandEventArgs e)
{
if (e.CommandName == "select")
{
Response.Redirect("goodsList.aspx?id="+e.CommandArgument);
}
}
public string GetClassName(int IntClassID)
{
return gcObj.GetClass(IntClassID);
}
protected void dlNewGoods_ItemCommand(object source, DataListCommandEventArgs e)
{
if (e.CommandName == "detailSee")
{
Session["address"] = "";
Session["address"] = "Default.aspx";
Response.Redirect("~/showInfo.aspx?id=" + Convert.ToInt32(e.CommandArgument.ToString()));
}
}
}
麻烦您了,谢谢了!
<table style="width: 204px; height:448px; font-size: 9pt; font-family: 宋体; vertical-align :top ; background-image: url(images/商品分类.jpg); background-repeat :no-repeat" border="0" cellpadding="0" cellspacing="0" >
<tr>
<td style="height: 35px">
</td>
</tr>
<tr align =center style="width: 204px; font-size: 9pt; font-family: 宋体; vertical-align :top ;">
<td>
<asp:DataList ID="dlClass" runat="server" OnItemCommand="dlClass_ItemCommand">
<ItemTemplate>
<table >
<tr>
<td align =left style ="width :28px; height :25px;vertical-align :bottom">
<asp:Image ID="imageIcon" runat="server" ImageUrl =<%#DataBinder.Eval(Container.DataItem,"CategoryUrl")%> />
</td>
<td> </td>
<td align =left style ="width :80px; height :25px; font-size: 9pt; font-family: 宋体; vertical-align :bottom " >
<asp:LinkButton ID="lnkbtnClass" runat="server" CommandName="select" CausesValidation="False" CommandArgument =<%#DataBinder.Eval(Container.DataItem,"ClassID") %>><%# DataBinder.Eval(Container.DataItem, "ClassName") %></asp:LinkButton>
</td>
</tr>
</table>
</ItemTemplate>
</asp:DataList>
</td>
</tr>
</table>
<table style="width: 204px; height: 181px; font-size: 9pt; font-family: 宋体; vertical-align :top ; text-align :center; background-image: url(images/新品上市.jpg); background-repeat :no-repeat" border="0" cellpadding="0" cellspacing="0">
<tr>
<td style="height: 31px; width: 204px;"></td>
</tr>
<tr>
<td style="width: 204px;">
<marquee direction="up" onmouseout="this.start()" onmouseover="this.stop()" scrollAmount="2" scrollDelay="7" style="width: 204px;height: 120px; font-size: 9pt; font-family: 宋体; vertical-align :top ; text-align :center; " >
<asp:DataList ID="dlNewGoods" runat="server" OnItemCommand="dlNewGoods_ItemCommand" >
<ItemTemplate>
<table border="0" cellspacing="0" style="font-size :9pt" align =center >
<tr>
<td align="center" colspan="1" rowspan="5">
<asp:ImageButton ID="ImageButton1" runat="server" CommandArgument='<%#DataBinder.Eval(Container.DataItem, "BookID")%>' CommandName="detailSee" ImageUrl='<%#DataBinder.Eval(Container.DataItem,"BookUrl") %>' /></td>
<td colspan="2" align="center">
</td>
</tr>
<tr>
<td align =left style="width: 51px; " >
类别名:
</td>
<td align =left style=" color:#D57421 " >
<%#GetClassName(Convert.ToInt32(DataBinder.Eval(Container.DataItem , "ClassID")))%>
</td>
</tr>
<tr>
<td align =left style="width: 51px">
书 名:
</td>
<td align =left>
<%#DataBinder.Eval(Container.DataItem, "BookName")%>
</td>
</tr>
<tr>
<td align =left style="width: 51px">
作 者:
</td>
<td align =left>
<%#DataBinder.Eval(Container.DataItem,"Author") %>
</td>
</tr>
<tr>
<td align =left style="width: 51px">
出版社:
</td>
<td align =left>
<%#DataBinder.Eval(Container.DataItem,"Company") %>
</td>
</tr>
</table>
</ItemTemplate>
<HeaderStyle Font-Bold="False" Font-Italic="False" Font-Overline="False" Font-Strikeout="False"
Font-Underline="False" ForeColor="Blue" HorizontalAlign="Center" />
</asp:DataList></marquee>
</td>
</tr>
</table>
下面是navigate.ascx.cs页面的代码:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class userControl_navigate : System.Web.UI.UserControl
{
GoodsClass gcObj = new GoodsClass();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
gcObj.DLClassBind(this.dlClass);
gcObj.DLNewGoods(this.dlNewGoods);
}
}
protected void dlClass_ItemCommand(object source, DataListCommandEventArgs e)
{
if (e.CommandName == "select")
{
Response.Redirect("goodsList.aspx?id="+e.CommandArgument);
}
}
public string GetClassName(int IntClassID)
{
return gcObj.GetClass(IntClassID);
}
protected void dlNewGoods_ItemCommand(object source, DataListCommandEventArgs e)
{
if (e.CommandName == "detailSee")
{
Session["address"] = "";
Session["address"] = "Default.aspx";
Response.Redirect("~/showInfo.aspx?id=" + Convert.ToInt32(e.CommandArgument.ToString()));
}
}
}
麻烦您了,谢谢了!