📄 userfavor.aspx.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;
using System.Reflection;
public partial class userfavor : System.Web.UI.Page,ICallbackEventHandler
{
protected void Page_Load(object sender, EventArgs e)
{
ImageButton1.Attributes.Add("onclick","select1();return false;");
ImageButton2.Attributes.Add("onclick", "select2();return false;");
Button1.Attributes.Add("onclick","safe();return false;");
//从cookie中获取身份验证票信息
string cookieName = FormsAuthentication.FormsCookieName;
HttpCookie authCookie = Context.Request.Cookies[cookieName];
if(authCookie!=null)
{
//解密
FormsAuthenticationTicket authTicket = FormsAuthentication.Decrypt(authCookie.Value);
string name = authTicket.Name.ToString();
DataVisit mydv = new DataVisit();
DataSet myds=mydv.getfavor(name);
GridView1.DataSource = myds;
GridView1.DataBind();
}
}
public string result;
public string GetCallbackResult()
{
//为便于查看加载效果,添加延时
System.Threading.Thread.Sleep(1000);
string[] parts = result.Split('|');
//搜索名为MethodName的方法
MethodInfo method = this.GetType().GetMethod(parts[0]);
//定义一个object数组用来保存参数
object[] args = new object[parts.Length - 1];
Array.Copy(parts, 1, args, 0, args.Length);
return (string)method.Invoke(this, args);
}
public void RaiseCallbackEvent(string eventArgument)
{
result = eventArgument;
}
public string safe(string pwd,string email,string phone,string qq)
{
//从cookie中获取身份验证票信息
string cookieName = FormsAuthentication.FormsCookieName;
HttpCookie authCookie = Context.Request.Cookies[cookieName];
if (authCookie != null)
{
//解密
FormsAuthenticationTicket authTicket = FormsAuthentication.Decrypt(authCookie.Value);
string name = authTicket.Name.ToString();
DataVisit mydv = new DataVisit();
mydv.change(name, pwd, email, phone, qq);
return "修改成功了!";
}
else
{ return "修改失败了!";}
}
protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("onmouseover", "currentcolor=this.style.backgroundColor;this.style.backgroundColor='#e4f5d1';");
//当鼠标移走时还原该行的背景色
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=currentcolor");
}
}
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
LinkButton lb = (LinkButton)e.Row.FindControl("LinkButton1");
lb.Attributes.Add("onclick","javascript:return confirm('是否删除该影片?')");
}
}
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Delete")
{
//从cookie中获取身份验证票信息
string cookieName = FormsAuthentication.FormsCookieName;
HttpCookie authCookie = Context.Request.Cookies[cookieName];
if (authCookie != null)
{
//解密
FormsAuthenticationTicket authTicket = FormsAuthentication.Decrypt(authCookie.Value);
string name = authTicket.Name.ToString();
DataVisit mydv = new DataVisit();
string filmid = e.CommandArgument.ToString();
mydv.deletefilm(Convert.ToInt32(filmid), name);
DataSet myds = mydv.getfavor(name);
GridView1.DataSource = myds;
GridView1.DataBind();
}
}
}
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -