温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:Asp.net2.0的电影在线点播系统片段源码
当前文件:
MovieShowSample/userfavor.aspx.cs,打开代码结构图
MovieShowSample/userfavor.aspx.cs,打开代码结构图1using System; 2
using System.Data; 3
using System.Configuration; 4
using System.Collections; 5
using System.Web; 6
using System.Web.Security; 7
using System.Web.UI; 8
using System.Web.UI.WebControls; 9
using System.Web.UI.WebControls.WebParts; 10
using System.Web.UI.HtmlControls; 11
using System.Reflection; 12
public partial class userfavor : System.Web.UI.Page,ICallbackEventHandler 13
{ 14
protected void Page_Load(object sender, EventArgs e) 15
{ 16
ImageButton1.Attributes.Add("onclick","select1();return false;"); 17
ImageButton2.Attributes.Add("onclick", "select2();return false;"); 18
Button1.Attributes.Add("onclick","safe();return false;"); 19
20
//从cookie中获取身份验证票信息 21
string cookieName = FormsAuthentication.FormsCookieName; 22
HttpCookie authCookie = Context.Request.Cookies[cookieName]; 23
24
if(authCookie!=null) 25
{ 26
//解密 27
FormsAuthenticationTicket authTicket = FormsAuthentication.Decrypt(authCookie.Value); 28
string name = authTicket.Name.ToString(); 29
30
DataVisit mydv = new DataVisit(); 31
DataSet myds=mydv.getfavor(name); 32
GridView1.DataSource = myds; 33
GridView1.DataBind(); 34
} 35
36
} 37
38
39
public string result; 40
public string GetCallbackResult() 41
{ 42
//为便于查看加载效果,添加延时 43
System.Threading.Thread.Sleep(1000); 44
45
string[] parts = result.Split('|'); 46
//搜索名为MethodName的方法 47
MethodInfo method = this.GetType().GetMethod(parts[0]); 48
49
//定义一个object数组用来保存参数 50
object[] args = new object[parts.Length - 1]; 51
Array.Copy(parts, 1, args, 0, args.Length); 52
53
return (string)method.Invoke(this, args); 54
} 55
56
public void RaiseCallbackEvent(string eventArgument) 57
{ 58
result = eventArgument; 59
} 60
public string safe(string pwd,string email,string phone,string qq) 61
{ 62
//从cookie中获取身份验证票信息 63
string cookieName = FormsAuthentication.FormsCookieName; 64
HttpCookie authCookie = Context.Request.Cookies[cookieName]; 65
66
67
if (authCookie != null) 68
{ 69
70
//解密 71
FormsAuthenticationTicket authTicket = FormsAuthentication.Decrypt(authCookie.Value); 72
string name = authTicket.Name.ToString(); 73
74
DataVisit mydv = new DataVisit(); 75
mydv.change(name, pwd, email, phone, qq); 76
return "修改成功了!"; 77
78
} 79
else 80
{ return "修改失败了!";} 81
82
83
} 84
85
protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e) 86
{ 87
if (e.Row.RowType == DataControlRowType.DataRow) 88
{ 89
e.Row.Attributes.Add("onmouseover", "currentcolor=this.style.backgroundColor;this.style.backgroundColor='#e4f5d1';"); 90
//当鼠标移走时还原该行的背景色 91
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=currentcolor"); 92
} 93
} 94
95
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) 96
{ 97
if (e.Row.RowType == DataControlRowType.DataRow) 98
{ 99
LinkButton lb = (LinkButton)e.Row.FindControl("LinkButton1"); 100
lb.Attributes.Add("onclick","javascript:return confirm('是否删除该影片?')"); 101
} 102
} 103
104
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) 105
{ 106
if (e.CommandName == "Delete") 107
{ 108
//从cookie中获取身份验证票信息 109
string cookieName = FormsAuthentication.FormsCookieName; 110
HttpCookie authCookie = Context.Request.Cookies[cookieName]; 111
112
if (authCookie != null) 113
{ 114
//解密 115
FormsAuthenticationTicket authTicket = FormsAuthentication.Decrypt(authCookie.Value); 116
string name = authTicket.Name.ToString(); 117
118
DataVisit mydv = new DataVisit(); 119
string filmid = e.CommandArgument.ToString(); 120
mydv.deletefilm(Convert.ToInt32(filmid), name); 121
DataSet myds = mydv.getfavor(name); 122
GridView1.DataSource = myds; 123
GridView1.DataBind(); 124
} 125
} 126
} 127
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) 128
{ 129
130
} 131
} 132





}
}