温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:Asp.net+Flash实现无刷新上传
当前文件:
FlashUpload/Default.aspx.cs,打开代码结构图
FlashUpload/Default.aspx.cs,打开代码结构图1using System; 2
using System.Data; 3
using System.Configuration; 4
using System.Web; 5
using System.Web.Security; 6
using System.Web.UI; 7
using System.Web.UI.WebControls; 8
using System.Web.UI.WebControls.WebParts; 9
using System.Web.UI.HtmlControls; 10
11
//该源码下载自www.51aspx.com(51aspx.com) 12
public partial class _Default : System.Web.UI.Page 13
{ 14
protected void Page_Load(object sender, EventArgs e) 15
{ 16
// allows the javascript function to do a postback and call the onClick method 17
// associated with the linkButton LinkButton1. 18
string jscript = "function UploadComplete(){"; 19
jscript += string.Format("__doPostBack('{0}','');", LinkButton1.ClientID.Replace("_", "$")); 20
jscript += "};"; 21
Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "FileCompleteUpload", jscript, true); 22
} 23
protected string GetFlashVars() 24
{ 25
// Adds query string info to the upload page 26
// you can also do something like: 27
// return "?" + Server.UrlEncode("CategoryID="+CategoryID); 28
// we UrlEncode it because of how LoadVars works with flash, 29
// we want a string to show up like this 'CategoryID=3&UserID=4' in 30
// the uploadPage variable in flash. If we passed this string withou 31
// UrlEncode then flash would take UserID as a seperate LoadVar variable 32
// instead of passing it into the uploadPage variable. 33
// then in the httpHandler we get the CategoryID and UserID values from 34
// the query string. See Upload.cs in App_Code 35
// From 51aspx.com 36
return "?" + Server.UrlEncode(Request.QueryString.ToString()); 37
} 38
protected void LinkButton1_Click(object sender, EventArgs e) 39
{ 40
// Do something that needs to be done such as refresh a gridView 41
// say you had a gridView control called gvMyGrid displaying all 42
// the files uploaded. Refresh the data by doing a databind here. 43
// gvMyGrid.DataBind(); 44
} 45
} 46





}
}