在选择商品类别下拉菜单时出现
Microsoft JScript runtime error: Sys.WebForms.PageRequestManagerServerErrorException: 在服务器上处理请求时出现未知错误。服务器返回的状态码为: 404
- HTML code
-
<!--
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
--><%@ Page Language="C#" AutoEventWireup="true" CodeBehind="添加商品.aspx.cs" Inherits="汇通玩具网站.admin.商城.添加商品" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>添加商品</title>
<style type="text/css">
.style1
{
text-align: center;
}
.style2
{
text-align: center;
font-weight: bold;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<table style="width:40%;">
<tr>
<td class="style2" colspan="2">
添加商品</td>
</tr>
<tr>
<td class="style1">
商品类别</td>
<td>
<asp:DropDownList ID="商品类别列表" runat="server" Width="127px" AutoPostBack="True"
onselectedindexchanged="商品类别列表_SelectedIndexChanged">
</asp:DropDownList>
</td>
</tr>
<tr>
<td class="style1">
商品名称</td>
<td>
<asp:TextBox ID="商品名称" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td class="style1">
商品小图上传</td>
<td>
<asp:FileUpload ID="商品小图" runat="server" />
</td>
</tr>
<tr>
<td class="style1">
商品大图上传</td>
<td>
<asp:FileUpload ID="商品大图" runat="server" />
</td>
</tr>
<tr>
<td class="style1">
商品规格</td>
<td>
<asp:TextBox ID="商品规格" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td class="style1">
商品面料</td>
<td>
<asp:TextBox ID="商品面料" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td class="style1">
商品A价</td>
<td>
<asp:TextBox ID="商品A价" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td class="style1">
商品B价</td>
<td>
<asp:TextBox ID="商品B价" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td class="style1">
是否精品</td>
<td>
<asp:CheckBox ID="是否精品" runat="server" />
</td>
</tr>
<tr>
<td class="style1">
</td>
<td>
</td>
</tr>
</table>
</ContentTemplate>
</asp:UpdatePanel> <asp:Button ID="提交" runat="server" Text="提交" onclick="提交_Click" />
<asp:LinkButton ID="LinkButton1" runat="server" onclick="LinkButton1_Click"></asp:LinkButton>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
</form>
</body>
</html>
- C# code
-
<!--
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
-->using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using 商城;
namespace 汇通玩具网站.admin.商城
{
public partial class 添加商品 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
//商品 商品1 = new 商品();
商品类别 商品类别1 = new 商品类别();
商品类别1.数据库连接字符串 = ConfigurationManager.ConnectionStrings["汇通玩具网站ConnectionString"].ToString();
商品类别1.列出第一级商品类别存储过程名 = "列出第一级商品类别存储过程";
商品类别1.列出该级下的商品类别存储过程名 = "列出该级下的商品类别存储过程";
商品类别列表.DataSource = 商品类别1.列出所有商品类别();
商品类别列表.DataTextField = "商品类别名称";
商品类别列表.DataValueField = "商品类别编号";
商品类别列表.DataBind();
商品类别1.清空输出表();
}
protected void 提交_Click(object sender, EventArgs e)
{
string 文件名 = 商品小图.FileName;
string 文件大小 = 商品小图.PostedFile.ContentLength.ToString();
string 文件名后缀 = 文件名.Substring(文件名.LastIndexOf(".") + 1).ToLower();
商品 商品1 = new 商品();
商品1.商品类别编号 = Convert.ToInt32(商品类别列表.SelectedValue);
商品1.商品名称 = 商品名称.Text;
商品1.商品A价 = Convert.ToDouble(商品A价.Text);
商品1.商品B价 = Convert.ToDouble(商品B价.Text);
商品1.商品规格 = 商品规格.Text;
商品1.商品面料 = 商品面料.Text;
商品1.是否精品 = 是否精品.Checked;
string datetime = DateTime.Now.Date.ToString("yyyyMMdd");
string time = DateTime.Now.ToShortTimeString().Replace(":", "");
string 新文件名 = datetime + time + DateTime.Now.Millisecond.ToString();
string 大图上传完整路径 = Server.MapPath("上传图片/大图/") + 新文件名 + @"." + 文件名后缀;
商品大图.SaveAs(大图上传完整路径);
string 小图上传完整路径 = Server.MapPath("上传图片/小图/") + 新文件名 + @"." + 文件名后缀;
商品小图.SaveAs(小图上传完整路径);
商品1.商品大图地址 = "上传图片/大图/" + 新文件名 + @"."+ 文件名后缀;
商品1.商品小图地址 = "上传图片/小图/" + 新文件名 + @"." + 文件名后缀;
商品1.数据库连接字符串 = ConfigurationManager.ConnectionStrings["汇通玩具网站ConnectionString"].ToString();
商品1.添加商品存储过程名 = "添加商品存储过程";
商品1.添加商品();
UpdatePanel1.Visible = false;
提交.Visible = false;
LinkButton1.Visible = true;
LinkButton1.Text = "点击继续添加";
}
protected void LinkButton1_Click(object sender, EventArgs e)
{
商品名称.Text = "";
商品A价.Text = "";
商品B价.Text = "";
商品规格.Text = "";
商品面料.Text = "";
UpdatePanel1.Visible = true;
提交.Visible = true;
LinkButton1.Visible=false;
}
protected void 商品类别列表_SelectedIndexChanged(object sender, EventArgs e)
{
Label1.Text = 商品类别列表.SelectedValue.ToString();
}
}
}