ASP.NET从入门到精通31章无法打开首页
发表在ASP.NET图书答疑 2013-02-20
是否精华
版块置顶:
每次打开Default.aspx都会跳到error.aspx,这是咋回事啊?望指教,谢谢!
分享到:
精彩评论 3
小科_mrkj
学分:43 LV2
2013-02-20
沙发
读者朋友:
     您好,你可以用VS开发环境打开这个程序,然后在登录按钮的Click事件中插入断点,看看是运行到那块出现的问题。
szhongtian
学分:0 LV1
TA的每日心情
擦汗
2020-11-10 11:01:11
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">
                            &nbsp;</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()));
        }

    }
}
麻烦您了,谢谢了!
小科_mrkj
学分:43 LV2
2013-03-14
地板
读者朋友:
     您好,代码是没有问题的,主要看一下数据库中是否存在数据,然后再检查一下页面中绑定的数据表字段是否都存在。
首页上一页 1 下一页尾页 3 条记录 1/1页
手机同步功能介绍
友情提示:以下图书配套资源能够实现手机同步功能
明日微信公众号
明日之星 明日之星编程特训营
客服热线(每日9:00-17:00)
400 675 1066
mingrisoft@mingrisoft.com
吉林省明日科技有限公司Copyright ©2007-2022,mingrisoft.com, All Rights Reserved长春市北湖科技开发区盛北大街3333号长春北湖科技园项目一期A10号楼四、五层
吉ICP备10002740号-2吉公网安备22010202000132经营性网站备案信息 营业执照