|
C#代码:
- <mce:script runat="server"><!--
- ProductBLL ProductInfo = new ProductBLL();
- int ID;
- ProductCategoryBLL Category = new ProductCategoryBLL();
- protected int hit = 1;
- string Name = string.Empty;
- string Title = string.Empty;
- protected string CategoryInfo;
- protected string TitleKey;
- string ModifyTime;
- protected string Content = string.Empty;
- protected string ParentTitle = string.Empty;
-
- InfoBLL InfoMethod = new InfoBLL();
- protected string Keyword;
- protected string Pic;
- protected string PictureUrl;
- protected string Price = string.Empty;
- string MemberName = string.Empty;
-
- CommentsBLL CommentMethod = new CommentsBLL();
- Comments Comment = new Comments();
-
- protected void Page_Load(object sender, EventArgs e)
- {
- AjaxPro.Utility.RegisterTypeForAjax(GetType());
-
- ID = FormUtil.GetQueryInt("ID");
-
- DataTable DT = Category.GetDataByID(ID, "laozhuangProduct");
-
- if (DT.Rows.Count > 0)
- {
- Title = DT.Rows[0][1].ToString();
- ModifyTime = Convert.ToDateTime(DT.Rows[0][2].ToString()).ToShortDateString();
- Content = DT.Rows[0][11].ToString();
- PictureUrl = DT.Rows[0][12].ToString();
- hit += Convert.ToInt32(DT.Rows[0][14].ToString());
- Price = DT.Rows[0]["Keyword"].ToString();
- Category.Update(ID, "laozhuangProduct", hit);
- ParentTitle = Category.GetTitle(Convert.ToInt32(DT.Rows[0][15].ToString()), "laozhuangProductCategory");
- }
- MemberName = FormUtil.GetCookieString("Member");
- if (MemberName.Equals(""))
- {
- MemberName = "匿名用户";
- }
- ShowTitle();
- }
- public void ShowTitle()
- {
- DataTable Dt = InfoMethod.GetDataByID(1, "laozhuangInfo");
- if (Dt.Rows.Count > 0)
- {
- Keyword = Dt.Rows[0][1].ToString();
- }
- }
- [AjaxPro.AjaxMethod]
- public int Num(string Results)
- {
- int i=0;
- string User = string.Empty;
- string Mail = string.Empty;
- string rank = string.Empty;
- string r = string.Empty;
- string Content = string.Empty;
- string tit = string.Empty;
- int pid = 0;
- string[] str = Results.Split(',');
- if(str.Length>0)
- {
- User = str[0].ToString();
- Mail = str[1].ToString();
- rank = str[2].ToString();
- Content = str[3].ToString();
- pid = int.Parse(str[4].ToString());
- tit = str[5].ToString();
- }
-
- switch (r)
- {
- case "0":
- rank = "images/stars.gif";
- break;
- case "1":
- rank = "images/stars1.gif";
- break;
- case "2":
- rank = "images/stars2.gif";
- break;
- case "3":
- rank = "images/stars3.gif";
- break;
- case "4":
- rank = "images/stars4.gif";
- break;
- default:
- rank = "images/stars5.gif";
- break;
- }
- Comment.MemberName = User;
- Comment.EMail = Mail;
- Comment.Keyword = rank;
- Comment.Description = Content;
- Comment.ProductID = pid;
- Comment.Title = tit;
- if (CommentMethod.Insert(Comment, "") > 0)
- {
- i = 1;
- }
- else
- {
- i = 0;
- }
- return i;
- }
-
JS代码:
- <mce:script type="text/javascript"><!--
- var XMLHttp;
- var pid;
- var tit;
- var $=function(id)
- {
- return document.getElementById(id);
- }
- function SubmitInfo()
- {
- var user=$("user").innerHTML;
- var mail=$("mail").value;
- var radioChk=document.getElementsByName("rank");
- var rank;
- var content=$("content").value;
- for(var i=0;i<radioChk.length;i++)
- {
- if(radioChk[i].checked)
- {
- rank=radioChk[i].value;
- }
- }
- var results=user+','+mail+','+rank+','+content+','+pid+','+tit;
- ASP.wsgw_info_aspx.Num(results,callback)
- }
- function callback(res)
- {
- if(res.value==1)
- {
- setTimeout(ShowInfo,1000);
- }
- }
- function CreateXmlHttpRequest()
- {
-
- if(window.XMLHttpRequest)
- {
-
- XMLHttp=new XMLHttpRequest();
- }
-
- else if(window.ActiveXObject)
- {
- try
- {
- XMLHttp=new ActiveXObject("Msxml2.XMLHttp");
- }
- catch (e)
- {
- try
- {
- XMLHttp=new ActiveXObject("Microsoft.XMLHttp");
- }
- catch(e)
- {
-
- }
- }
- }
- }
-
- function ShowInfo()
- {
- CreateXmlHttpRequest();
- if(XMLHttp==null)
- {
- return;
- }
- XMLHttp.open("POST","UserHandler/UserComment.ashx?ID="+pid,true);
- XMLHttp.onreadystatechange=StateChange;
- XMLHttp.send(null);
- }
- function StateChange()
- {
- if(XMLHttp.readyState==4)
- {
- if(XMLHttp.status==200)
- {
- var res=XMLHttp.responseText;
- $("Comments").innerHTML=res;
- }
- }
- }
- function GetTitle()
- {
- pid=<%=ID %>;
- tit='<%=Title %>';
- }
-
-
HTML
- div id="Comments">
-
- </div>
(责任编辑:admin) |