日期:2014-05-17  浏览次数:20549 次

如何把代码套入母版页?
现在网页上有一个site.master的母版页,在网上下载了一个好的上传代码,可是我想把它这个代码套入我自己的母版页,这样会好看点。应该如何更改呀?谢谢。我在<%@ Page这个更改成了Control,但是不行?<%@ Page Language="C#" %>
<%@ Register Assembly="MattBerseth.WebControls.AJAX" Namespace="MattBerseth.WebControls.AJAX.Progress" TagPrefix="mb" %>

<!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>Untitled Page</title>
  <link rel="Stylesheet" href="_assets/css/progress.css" />
  <link rel="Stylesheet" href="_assets/css/upload.css" />
  <style type="text/css">
  BODY{ font-family:Arial, Sans-Serif; font-size:12px;}
  </style>
  <script type="text/C#" runat="server">
   
  protected void Page_Load(object sender, EventArgs args)
  {
  if (!this.IsPostBack)
  {  
  this.Session["UploadInfo"] = new UploadInfo { IsReady = false };
  }
  }
   
  /// <summary>
  /// 
  /// </summary>
  [System.Web.Services.WebMethod]
  [System.Web.Script.Services.ScriptMethod]
  public static object GetUploadStatus()
  {
  //获取文件长度
  UploadInfo info = HttpContext.Current.Session["UploadInfo"] as UploadInfo;

  if (info != null && info.IsReady)
  {
  int soFar = info.UploadedLength;
  int total = info.ContentLength;

  int percentComplete = (int)Math.Ceiling((double)soFar / (double)total * 100);
  string message = string.Format("上传 {0} ... {1} of {2} 字节", info.FileName, soFar, total);
   
  // 返回百分比
  return new { percentComplete = percentComplete, message = message };
  }

  // 还没有准备好...
  return null;
  }
   
  </script>
</head>
<body>
  <form id="form1" runat="server">
  <asp:ScriptManager ID="scriptManager" runat="server" EnablePageMethods="true" />
   
  <script type="text/javascript">
  var intervalID = 0;
  var progressBar;
  var fileUpload;
  var form;  
  // 进度条  
  function pageLoad(){  
  $addHandler($get('upload'), 'click', onUploadClick);
  progressBar = $find('progress');
  }
  // 注册表单  
  function register(form, fileUpload){  
  this.form = form;
  this.fileUpload = fileUpload;
  }  
  //上传验证
  function onUploadClick() {  
  var vaild = fileUpload.value.length > 0;
  if(vaild){  
  $get('upload').disabled = 'disabled';