<script type="text/javascript" language="javascript"> function MDown(Object){ function MMove(){ function MUp(){ massage_box.style.left = (document.body.clientWidth - w) / 2;
|
<input onclick="clickMe()" type="button" value="点我点我" />
==============================
另外自己找三张图片用以代替message的图片:warning.gif、error.gif、info.gif
===============================================================
===============================================================
还有另外一种是这种:
function Shop()
{
openWithIframe("已成功添加到购物车!","ShoppingCart.aspx?addItem=ProID",240,110);
}
<input onclick="Shop()" type="button" value="点我点我" />
=================自己定义ShoppingCart.aspx中的内容
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ShoppingCart.aspx.cs" Inherits="Comm_ShoppingCart" %>
<!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>
<script type="text/javascript">
function LinkLartList()
{
window.parent.closeWithIframe()
window.open('CartList.aspx');
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div runat="server" id="div1">
<table width='100%' border='0' cellspacing='0' cellpadding='0'>
<tr style='font-size:12px;height:30px'>
<td align='center'>购物车共<strong> <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label></strong>种</td>
<td align='center'>合计:<strong><asp:Label ID="Label2" runat="server" Text="Label"></asp:Label></strong></td>
</tr>
<tr>
<td height='5px'></td><td></td>
</tr>
<tr>
<td align='center'><input type='submit' name='button' id='button' value='查看购物车' onclick="LinkLartList()" /></td>
<td align='center'><input type='button' onclick='javascript:window.parent.closeWithIframe();' name='button2' id='button2' value='继续购买' /></td>
</tr>
<tr>
<td align='center'>
</td>
<td align='center'> </td>
</tr>
</table>
</div>
</form>
</body>
</html>
--------------------------------------------------------------------------
using System;
using System.Collections;
using System.Configuration;
using System.Data;
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.Collections.Generic;
using System.Text;
using PetShop.Model;
using CHP.ProductPages;
using ChangeHope;
using System.Data.SqlClient;
public partial class Comm_ShoppingCart : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string itemId = Request.QueryString["addItem"];
if (Request.Cookies[ProductCMS.GetCookieName()] != null)
{
int yx_reuserid = Convert.ToInt32(Request.Cookies[ProductCMS.GetCookieName()].Values["CH_userid"]);
// Response.Write(Request["yx_user"] + " fggfgfgf " + Request.Cookies[ProductCMS.GetCookieName()].Values["CH_userid"]);
string sellerid = "";
YX_sql Exsql = new YX_sql();
string sql = "select YX_Userid from YX_Product where YX_ID=" + itemId + "";
SqlDataReader dr3 = Exsql.Re_dr(sql);
if (dr3.Read())
{
sellerid = dr3["YX_Userid"].ToString();
}
if (Convert.ToInt32(sellerid) == yx_reuserid)
{
// ChangeHope_fc.Show_Msg("你不能购买自己的商品!", "ShowProduct.aspx?YX_MID=" + itemId);
Response.Write("<script>alert('你不能购买自己的商品!');window.parent.closeWithIframe()</script>");
Response.End();
Response.End();
}
else
{
// string itemId = Request.QueryString["addItem"];
Profile.ShoppingCart.Add(itemId);
Profile.Save();
ShoppingCartControl();
//yx_reuserid = Convert.ToInt32(Request.Cookies[ProductCMS.GetCookieName()].Values["CH_userid"]);
//yx_reusername = ProductCMS.Decrypt(Request.Cookies[ProductCMS.GetCookieName()].Values["CH_username"]);
}
}
else
{
// ChangeHope_fc.Show_Msg("你还没有登陆,请登陆!", "Default.aspx");
Response.Write("<script>alert('你还没有登录,请登录');window.parent.closeWithIframe()</script>");
Response.End();
}
}
/// <summary>
/// 显示商品种类和总价格
/// </summary>
public void ShoppingCartControl()
{
int count = 0;
decimal totle = 0;
//ProfileCommon Profile = new ProfileCommon();
StringBuilder shtml = new StringBuilder();
ICollection<CartItemInfo> cart = Profile.ShoppingCart.CartItems;//ShoppingCart.CartItems;
if (cart.Count > 0)
{
shtml.Append("<div id=/"ShopInfo/">");
foreach (CartItemInfo info in cart)
{
count++;
totle = totle + Convert.ToDecimal(info.Price) * Convert.ToInt32(info.Quantity);
}
Label1.Text = count.ToString();
Label2.Text = totle.ToString();
}
}
}