Feeds:
文章
评论

Archive for 2009年10月

Win7终于发布了

在开启UAC的时候,在win7中执行程序默认是以一种权限较低的方式执行的,但是在这种方式下,我们有些操作会失败(比如修改注册表,监听端口,往系统目录写入文件等),要实现这些操作,就需要我们以管理员权限执行程序了。

当然,只有在程序上右键,选择“以管理员执行”就可以,不过如何让程序自己自动以管理员权限来运行呢,这就需要Manifest了。

首先我们来新建个项目(懒得改名字了,就叫WindowsFormsApplication1吧)

image

 

按F5执行下(恩,貌似没有啥问题[空文档,有问题才怪… ])

image

 

然后我们添加Manifest(中文版叫“应用程序清单文件”)

image

image

 

下面我们看下Manifest的内容

<?xml version="1.0" encoding="utf-8"?>
<asmv1:assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
    <security>
      <requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
        <!-- UAC 清单选项
            如果希望更改 Windows 用户帐户控制级别,请用以下节点之一替换 
            requestedExecutionLevel 节点。
        <requestedExecutionLevel  level="asInvoker" uiAccess="false" />
        <requestedExecutionLevel  level="requireAdministrator" uiAccess="false" />
        <requestedExecutionLevel  level="highestAvailable" uiAccess="false" />

          如果您希望利用文件和注册表虚拟化提供
            向后兼容性,请删除 requestedExecutionLevel 节点。
        -->
        <requestedExecutionLevel level="asInvoker" uiAccess="false" />
      </requestedPrivileges>
    </security>
  </trustInfo>
</asmv1:assembly>
 
 
内容里的说明够详细了吧,只要把 asInvoker替换成requireAdministrator,我们的程序就会默认要求管理员权限运行了,该下执行试试效果。
恩,窗口弹出来了。
image 
看下程序图标:
image 

大功告成…

 

 

下面再说下怎么给程序的按钮上也加上小盾牌图标吧

这我们就需要调用Win32 API了

要调用API么,要先引用命名空间

using System.Runtime.InteropServices;

 

然后调用API

        [DllImport("user32.dll")]
        private static extern IntPtr SendMessage(HandleRef hWnd, uint Msg, IntPtr wParam, IntPtr lParam);

        ///////////////////////////////////////////////////////////////////////
        /// <summary>
        ///     Enables the elevated shield icon on the given button control
        /// </summary>
        /// <param name="ThisButton">
        ///     Button control to enable the elevated shield icon on.
        /// </param>
        ///////////////////////////////////////////////////////////////////////
        private void EnableElevateIcon_BCM_SETSHIELD(Button ThisButton)
        {
            // Input validation, validate that ThisControl is not null
            if (ThisButton == null)
            {
                return;
            }

            // Define BCM_SETSHIELD locally, declared originally in Commctrl.h
            uint BCM_SETSHIELD = 0x0000160C;

            // Set button style to the system style
            ThisButton.FlatStyle = FlatStyle.System;

            // Send the BCM_SETSHIELD message to the button control
            SendMessage(new HandleRef(ThisButton, ThisButton.Handle), BCM_SETSHIELD, new IntPtr(0), new IntPtr(1));
        }

 

在Form上拖个Button,拖大一点哦,小了图标看不清

image

然后在Form1_Load里,用API把图标加到Button1上

        private void Form1_Load(object sender, EventArgs e)
        {
            EnableElevateIcon_BCM_SETSHIELD(button1);
        }
最后执行看下效果吧!
image 
 
恩?盾牌为啥有点不一样呢,上面那个图标是server08上的,win7上应该是下面这样:
image 
 
有错误的地方欢迎指出。

Read Full Post »

文件名 en_visual_studio_2010_ultimate_beta_2_x86_dvd_444661.iso 
邮寄日期 (UTC): 10/19/2009 7:57:47 AM ISO/CRC: 2C3975FB
SHA1: 7098953C9B73DB7F0245D613143D15F85BA52264  

 

1.微软官方下载(分成4+3个包):
VS2010B2TFS
http://download.microsoft.com/download/1/B/7/1B71259E-9D37-4EB7-BC8A-1B53DF7C7D86/VS2010B2TFS_3PartsTotal.part1.exe
http://download.microsoft.com/download/1/B/7/1B71259E-9D37-4EB7-BC8A-1B53DF7C7D86/VS2010B2TFS_3PartsTotal.part2.rar
http://download.microsoft.com/download/1/B/7/1B71259E-9D37-4EB7-BC8A-1B53DF7C7D86/VS2010B2TFS_3PartsTotal.part3.rar
VS2010B2Ult
http://download.microsoft.com/download/F/A/1/FA1DAEA6-B719-461D-96B0-31C9C63680C8/VS2010B2Ult_4PartsTotal.part1.exe
http://download.microsoft.com/download/F/A/1/FA1DAEA6-B719-461D-96B0-31C9C63680C8/VS2010B2Ult_4PartsTotal.part2.rar
http://download.microsoft.com/download/F/A/1/FA1DAEA6-B719-461D-96B0-31C9C63680C8/VS2010B2Ult_4PartsTotal.part3.rar

http://download.microsoft.com/download/F/A/1/FA1DAEA6-B719-461D-96B0-31C9C63680C8/VS2010B2Ult_4PartsTotal.part4.rar
2.BT下载:
http://www.u-tide.com/fish/temp/en_visual_studio_2010_ultimate_beta_2_x86_dvd_444661.iso.zip
3.电驴下载:
ed2k://|file|en_visual_studio_2010_ultimate_beta_2_x86_dvd_444661.iso|2342531072|F39C917D711794080FFBE396CBD6F322|/
4.在线安装:
http://www.microsoft.com/visualstudio/en-us/try/default.mspx#download (BootStrapper 在线安装,安装程序如下)

Microsoft® Visual Studio 2010 Professional Edition Beta 2 – Web Installer

Microsoft® Visual Studio 2010 Premium Edition Beta 2 – Web Installer

Microsoft® Visual Studio 2010 Ultimate Edition Beta 2 – Web Installer

Microsoft® .NET Framework 4 Beta 2 (x86, x64, ia64) – Web Installer

Microsoft® .NET Framework 4 Beta 2 Client Profile (x86 and x64) – Web Installer

 

 

详细介绍可以看博客园新闻:http://news.cnblogs.com/n/50045/

Read Full Post »

AjaxControlToolkit–HtmlEditor

       HtmlEditor在AjaxControlToolkit的上个版本中就已经提供了,属于一个功能比较简单的Html在线编辑器,虽说功能不多,不过对只需要基础的应用差不多已经足够了。

       使用HtmlEditor很简单,只要在页面上注册了AjaxControlToolkit,先望页面里拖个拖个ScriptManager进去,再从工具箱里把Editor拖出来就行了(前提是已添加了AjaxControlToolkit的引用,并将所包含的控件放到了工具箱)

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="editor.aspx.cs" Inherits="editor" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit.HTMLEditor"
    TagPrefix="cc1" %>
<!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></title>
    <script type="text/javascript">
    
      function pageLoad() {
      }
    
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:ScriptManager ID="ScriptManager1" runat="server" />
        <cc1:Editor ID="Editor1" runat="server" Width="500px" Height="300px"/>
    </div>
    </form>
</body>
</html>
 

       上个图看下效果:

image

       挺傻瓜化的吧。

       其实HtmlEditor的最大好处是我们可以方便的自己定义在HTML编辑器上所需要的功能。

       下面让我们先来添加一个类:myeditor.cs

       在其中添加三个引用命名空间:

using AjaxControlToolkit.HTMLEditor;
using System.Collections;
using System.Collections.ObjectModel;

       然后添加自己的命名空间(这里就叫myhtmleditor吧),然后添加一个类(这里我们叫myeditor吧)继承自Editor

namespace myhtmleditor
{
    public class myeditor:Editor
    {
    }
}

       然后我们重写两个事件FillTopToolbar和FillBottomToolbar就可以定制我们自己想要的HtmlEditor了

        protected override void FillTopToolbar()
        {
        }

        protected override void FillBottomToolbar()
        {
        }

      其中FillTopToolbar是HtmlEditor上方的菜单,FillBottomToolbar是HtmlEditor下方的菜单

      可以设定的有:

 

            //定义下拉菜单金集合
            Collection<AjaxControlToolkit.HTMLEditor.ToolbarButton.SelectOption> options;
            //定义下拉菜单
            AjaxControlToolkit.HTMLEditor.ToolbarButton.SelectOption option;
            //菜单栏上的分割符
            TopToolbar.Buttons.Add(new AjaxControlToolkit.HTMLEditor.ToolbarButton.HorizontalSeparator());
            //撤销
            TopToolbar.Buttons.Add(new AjaxControlToolkit.HTMLEditor.ToolbarButton.Undo());
            //重做
            TopToolbar.Buttons.Add(new AjaxControlToolkit.HTMLEditor.ToolbarButton.Redo());
            //加粗
            TopToolbar.Buttons.Add(new AjaxControlToolkit.HTMLEditor.ToolbarButton.Bold());
            //倾斜
            TopToolbar.Buttons.Add(new AjaxControlToolkit.HTMLEditor.ToolbarButton.Italic());
            //下划线
            TopToolbar.Buttons.Add(new AjaxControlToolkit.HTMLEditor.ToolbarButton.Underline());
            //文字中划线
            TopToolbar.Buttons.Add(new AjaxControlToolkit.HTMLEditor.ToolbarButton.StrikeThrough());
            //上标
            TopToolbar.Buttons.Add(new AjaxControlToolkit.HTMLEditor.ToolbarButton.SuperScript());
            //下标
            TopToolbar.Buttons.Add(new AjaxControlToolkit.HTMLEditor.ToolbarButton.SubScript());
            //从左向右排列
            TopToolbar.Buttons.Add(new AjaxControlToolkit.HTMLEditor.ToolbarButton.Ltr());
            //从右向左排列
            TopToolbar.Buttons.Add(new AjaxControlToolkit.HTMLEditor.ToolbarButton.Rtl());

            //文字颜色按钮
            TopToolbar.Buttons.Add(new AjaxControlToolkit.HTMLEditor.ToolbarButton.ForeColor());
            //文字颜色下拉菜单
            TopToolbar.Buttons.Add(new AjaxControlToolkit.HTMLEditor.ToolbarButton.ForeColorSelector());
            //取消文字颜色
            TopToolbar.Buttons.Add(new AjaxControlToolkit.HTMLEditor.ToolbarButton.ForeColorClear());

            //另一种定义文字颜色的方法
            AjaxControlToolkit.HTMLEditor.ToolbarButton.FixedForeColor FixedForeColor = new AjaxControlToolkit.HTMLEditor.ToolbarButton.FixedForeColor();
            TopToolbar.Buttons.Add(FixedForeColor);
            AjaxControlToolkit.HTMLEditor.ToolbarButton.ForeColorSelector ForeColorSelector = new AjaxControlToolkit.HTMLEditor.ToolbarButton.ForeColorSelector();
            TopToolbar.Buttons.Add(ForeColorSelector);
            TopToolbar.Buttons.Add(new AjaxControlToolkit.HTMLEditor.ToolbarButton.ForeColorClear());

            //文字背景色按钮
            TopToolbar.Buttons.Add(new AjaxControlToolkit.HTMLEditor.ToolbarButton.FixedBackColor());
            //文字背景色下来菜单
            TopToolbar.Buttons.Add(new AjaxControlToolkit.HTMLEditor.ToolbarButton.BackColorSelector());
            //取消文字背景色
            TopToolbar.Buttons.Add(new AjaxControlToolkit.HTMLEditor.ToolbarButton.BackColorClear());

            //清除格式
            TopToolbar.Buttons.Add(new AjaxControlToolkit.HTMLEditor.ToolbarButton.RemoveStyles());

            //文字字体
            AjaxControlToolkit.HTMLEditor.ToolbarButton.FontName fontName = new AjaxControlToolkit.HTMLEditor.ToolbarButton.FontName();
            TopToolbar.Buttons.Add(fontName);
            options = fontName.Options;
            option = new AjaxControlToolkit.HTMLEditor.ToolbarButton.SelectOption();
            option.Value = "arial,helvetica,sans-serif";
            option.Text = "Arial";
            options.Add(option);
            option = new AjaxControlToolkit.HTMLEditor.ToolbarButton.SelectOption();
            option.Value = "courier new,courier,monospace";
            option.Text = "Courier New";
            options.Add(option);
            option = new AjaxControlToolkit.HTMLEditor.ToolbarButton.SelectOption();
            option.Value = "georgia,times new roman,times,serif";
            option.Text = "Georgia";
            options.Add(option);
            option = new AjaxControlToolkit.HTMLEditor.ToolbarButton.SelectOption();
            option.Value = "tahoma,arial,helvetica,sans-serif";
            option.Text = "Tahoma";
            options.Add(option);
            option = new AjaxControlToolkit.HTMLEditor.ToolbarButton.SelectOption();
            option.Value = "times new roman,times,serif";
            option.Text = "Times New Roman";
            options.Add(option);
            option = new AjaxControlToolkit.HTMLEditor.ToolbarButton.SelectOption();
            option.Value = "verdana,arial,helvetica,sans-serif";
            option.Text = "Verdana";
            options.Add(option);
            option = new AjaxControlToolkit.HTMLEditor.ToolbarButton.SelectOption();
            option.Value = "impact";
            option.Text = "Impact";
            options.Add(option);
            option = new AjaxControlToolkit.HTMLEditor.ToolbarButton.SelectOption();
            option.Value = "wingdings";
            option.Text = "WingDings";
            options.Add(option);

            //文字字号
            AjaxControlToolkit.HTMLEditor.ToolbarButton.FontSize fontSize = new AjaxControlToolkit.HTMLEditor.ToolbarButton.FontSize();
            TopToolbar.Buttons.Add(fontSize);
            options = fontSize.Options;
            option = new AjaxControlToolkit.HTMLEditor.ToolbarButton.SelectOption();
            option.Value = "8pt";
            option.Text = "1 ( 8 pt)";
            options.Add(option);
            option = new AjaxControlToolkit.HTMLEditor.ToolbarButton.SelectOption();
            option.Value = "10pt";
            option.Text = "2 (10 pt)";
            options.Add(option);
            option = new AjaxControlToolkit.HTMLEditor.ToolbarButton.SelectOption();
            option.Value = "12pt";
            option.Text = "3 (12 pt)";
            options.Add(option);
            option = new AjaxControlToolkit.HTMLEditor.ToolbarButton.SelectOption();
            option.Value = "14pt";
            option.Text = "4 (14 pt)";
            options.Add(option);
            option = new AjaxControlToolkit.HTMLEditor.ToolbarButton.SelectOption();
            option.Value = "18pt";
            option.Text = "5 (18 pt)";
            options.Add(option);
            option = new AjaxControlToolkit.HTMLEditor.ToolbarButton.SelectOption();
            option.Value = "24pt";
            option.Text = "6 (24 pt)";
            options.Add(option);
            option = new AjaxControlToolkit.HTMLEditor.ToolbarButton.SelectOption();
            option.Value = "36pt";
            option.Text = "7 (36 pt)";
            options.Add(option);
            option = new AjaxControlToolkit.HTMLEditor.ToolbarButton.SelectOption();
            option.Value = "100pt";
            option.Text = "8 (100 pt)";
            options.Add(option);

            //剪切
            TopToolbar.Buttons.Add(new AjaxControlToolkit.HTMLEditor.ToolbarButton.Cut());
            //复制
            TopToolbar.Buttons.Add(new AjaxControlToolkit.HTMLEditor.ToolbarButton.Copy());
            //粘贴
            TopToolbar.Buttons.Add(new AjaxControlToolkit.HTMLEditor.ToolbarButton.Paste());
            TopToolbar.Buttons.Add(new AjaxControlToolkit.HTMLEditor.ToolbarButton.PasteText());
            TopToolbar.Buttons.Add(new AjaxControlToolkit.HTMLEditor.ToolbarButton.PasteWord());

            //增加缩进量
            TopToolbar.Buttons.Add(new AjaxControlToolkit.HTMLEditor.ToolbarButton.IncreaseIndent());
            //减少缩进量
            TopToolbar.Buttons.Add(new AjaxControlToolkit.HTMLEditor.ToolbarButton.DecreaseIndent());

            //插入分割线
            TopToolbar.Buttons.Add(new AjaxControlToolkit.HTMLEditor.ToolbarButton.InsertHR());
            //插入超链接
            TopToolbar.Buttons.Add(new AjaxControlToolkit.HTMLEditor.ToolbarButton.InsertLink());
            //取消超链接
            TopToolbar.Buttons.Add(new AjaxControlToolkit.HTMLEditor.ToolbarButton.RemoveLink());

            //编号
            TopToolbar.Buttons.Add(new AjaxControlToolkit.HTMLEditor.ToolbarButton.OrderedList());
            //项目编号
            TopToolbar.Buttons.Add(new AjaxControlToolkit.HTMLEditor.ToolbarButton.BulletedList());

            //分段
            TopToolbar.Buttons.Add(new AjaxControlToolkit.HTMLEditor.ToolbarButton.Paragraph());
            
	     //文本左对齐
            TopToolbar.Buttons.Add(new AjaxControlToolkit.HTMLEditor.ToolbarButton.JustifyLeft());
            //文本右对齐
            TopToolbar.Buttons.Add(new AjaxControlToolkit.HTMLEditor.ToolbarButton.JustifyRight());
            //居中
            TopToolbar.Buttons.Add(new AjaxControlToolkit.HTMLEditor.ToolbarButton.JustifyCenter());
            //两端对齐
            TopToolbar.Buttons.Add(new AjaxControlToolkit.HTMLEditor.ToolbarButton.JustifyFull());
            //取消对齐
            TopToolbar.Buttons.Add(new AjaxControlToolkit.HTMLEditor.ToolbarButton.RemoveAlignment());

            //设计视图
            BottomToolbar.Buttons.Add(new AjaxControlToolkit.HTMLEditor.ToolbarButton.DesignMode());
            //HTML视图
            BottomToolbar.Buttons.Add(new AjaxControlToolkit.HTMLEditor.ToolbarButton.HtmlMode());
            //预览视图
            BottomToolbar.Buttons.Add(new AjaxControlToolkit.HTMLEditor.ToolbarButton.PreviewMode());

 

       上面这些不论写在FillTopToolbar还是FillBottomToolbar都行,甚至两个一起写也可以(估计没这么BT的吧…)

       不过一般习惯上还是FillTopToolbar里写编辑菜单,FillBottomToolbar里面放视图模式…

       已经自定义好了编辑器,下面我们就要在页面里使用它了,打开我们的页面,在页面上注册我们钢材建立的命名空间,再在页面里添加就可以了

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="editor.aspx.cs" Inherits="editor" %>
<%@ Register Namespace="myhtmleditor" TagPrefix="myhtmleditor" %>
<!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></title>
    <script type="text/javascript">
      function pageLoad() {
      }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:ScriptManager ID="ScriptManager1" runat="server" />
        <myhtmleditor:myeditor ID="myeditor" runat="Server" Width="500px" Height="300px" />
    </div>
    </form>
</body>
</html>

 

       恩,最后上图看下效果(我这里把菜单全加上了,可以根据自己需要选择有用的菜单就可以了)

image

 

 

就写这些吧,有什么不对的地方望大家指出。

Read Full Post »

9月30日的AjaxControlToolkit 30930里增加了两个新的控件:AsyncFileUpload和Seadragon,貌似目前园子里还没人写过…

就试着自己写写吧

 

其实AjaxControlToolkit 挺傻瓜化的,先在VS建立歌网站,然后打开默认的default.aspx,拖个ScriptManager进去,添加下AjaxControlToolkit 的注册,然后拖个AsyncFileUpload进去,就基本能用了…

</p>
<p>&lt;%@ Page Language=&quot;C#&quot; AutoEventWireup=&quot;true&quot;  CodeFile=&quot;Default.aspx.cs&quot; Inherits=&quot;_Default&quot; %&gt; </p>
<p>&lt;%@ Register Assembly=&quot;AjaxControlToolkit&quot; Namespace=&quot;AjaxControlToolkit&quot; TagPrefix=&quot;cc1&quot; %&gt; </p>
<p>&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;<a href="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;">http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;</a>&gt; </p>
<p>&lt;html xmlns=&quot;<a href="http://www.w3.org/1999/xhtml&quot;">http://www.w3.org/1999/xhtml&quot;</a>&gt; <br />&lt;head runat=&quot;server&quot;&gt; <br />    &lt;title&gt;AsyncFileUpload&lt;/title&gt; <br />&lt;/head&gt; <br />&lt;body&gt; <br />    &lt;form id=&quot;form1&quot; runat=&quot;server&quot;&gt; <br />    &lt;div&gt; <br />        &lt;asp:ScriptManager ID=&quot;ScriptManager1&quot; runat=&quot;server&quot;&gt; <br />        &lt;/asp:ScriptManager&gt; <br />        &lt;cc1:AsyncFileUpload ID=&quot;AsyncFileUpload1&quot; runat=&quot;server&quot; /&gt; <br />    &lt;/div&gt; <br />    &lt;/form&gt; <br />&lt;/body&gt; <br />&lt;/html&gt;</p>
<p>

 

然后我们看下几个有用的属性吧:

属性

说明

CompleteBackColor 上传成功后显示的颜色(默认为淡黄绿色Lime)
ErrorBackColor 上传出错后显示的颜色(默认为红Red)
UploadingBackColor 正在上传时显示的颜色(默认为白)
UploaderStyle 有两种选择,Traditional 和 Modern,默认是Traditional,没大弄明白两者在实际中的区别,希望有明白的大大帮我解答一下吧
ThrobberID 在上传文件时显示的控件的ID,一般是用GIF图片
HasFile 返回一个布尔值,来判断是否存在文件

其他还有几乎控件都通用的Width,Length,Font,Border,CSS样式之类的属性就不介绍了

 

再来看下控件的事件吧:

事件

执行方式

说明

OnClientUploadError

Client

当上传出错事执行

OnClientUploadStarted

Client

当上传开始时执行

OnClientUploadComplete

Client

当上传完成时执行

onuploadedcomplete

Server

当上传完成时执行

 

有了属性和事件,就重新定义下我们的AsyncFileUpload吧:

 

我们首先需要个Image (当然,文本也可以),好在上传文件时页面上有点显示,这年头不是都强调用户体验嘛

<asp:Image ID="ImageUploading" runat="server" ImageUrl="/images/loader.gif"/>

还需要个Label,好显示上传前后的信息:

<asp:Label ID="Labeluploadstatus" runat="server" Text=""></asp:Label>

好了,现在可以定义我们的AsyncFileUpload了:

<cc1:AsyncFileUpload ID="AsyncFileUpload1" Width="300px" runat="server"
            OnClientUploadError="AsyncFileUpload1_UploadError" OnClientUploadStarted="AsyncFileUpload1_StartUpload"
            OnClientUploadComplete="AsyncFileUpload1_UploadComplete"
            CompleteBackColor="Lime" UploaderStyle="Modern"
            ErrorBackColor="Red" ThrobberID="ImageUploading"
            onuploadedcomplete="AsyncFileUpload1_UploadedComplete"
            UploadingBackColor="Blue" />

接着开始写JavaScript事件:

ranhou

首先是上传失败的提示:

function AsyncFileUpload1_UploadError(sender, args)
{
    document.getElementById(‘Labeluploadstatus’).innerText = "对不起,文件“" + args.get_fileName() + "”上传出错,原因:" + args.get_errorMessage() ;
}

然后是开始上传时的提示:

function AsyncFileUpload1_StartUpload(sender, args)
{
    document.getElementById(‘Labeluploadstatus’).innerText = "文件“" + args.get_fileName() + "”正在上传,请稍等…";
}

最后是上传完成后的提示:

function AsyncFileUpload1_UploadComplete(sender, args)
{
    document.getElementById(‘Labeluploadstatus’).innerText = "文件“" + args.get_fileName() + "”上传完成,文件大小:" + args.get_length() + " bytes";
}

然后就是写服务器事件了:

protected void AsyncFileUpload1_UploadedComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
    {
        System.Threading.Thread.Sleep(5000);//由于本机上传速度太快,所以延迟下好看上传时的效果
        //取当前时间,以时间+文件名来保存上传文件
        DateTime dt = DateTime.Now.ToLocalTime();
        //判断是否有文件,有则保存
        if (AsyncFileUpload1.HasFile)
        {
            //设置文件路径和文件名
            string strPath = MapPath("~/Uploads/") + dt.ToString().Trim().Replace("/", "-").Replace(":",":") + e.filename.ToString().Trim();
            //保存文件
            AsyncFileUpload1.SaveAs(strPath);
        }

    }

基本大功告成,上图看下效果吧:

image

image

image

image

image

 

 

大体就这些吧

另外那个Seadragon挺好玩的,要是能自动生成所需的图片和XML就更好了…

Read Full Post »

AJAX Control Toolkit 30930

十一假期还没怎么过就过完了

为啥放假总是过地这么快呢…

哎,又开始了天天和电脑搏斗的生活了…

 

上网偶然发现AJAX Control Toolkit在上个版本发布4个月后,9月30又更新了

这次更新了2个控件:

  • SeaDragon – This version of Seadragon allows you to display an image, and to zoom in and out of that image using mouse button keys without resizing the window.
  • AsyncFileUpload – This new control enables you to perform file uploads without doing a postback. The control displays a throbber image during upload and raises client and server events when the upload is complete. This control was contributed by Steven Lindsay.

详细请看:http://ajaxcontroltoolkit.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=33804

 

AsyncFileUpload ,顾名思义,就是上传文件了,贴图看下效果:

image

 

事件,属性和方法:

image

 

SeaDragon 是个挺好玩的东西哦,看名字眼熟吧,它就是来自微软的在线图片服务Seadragon(http://livelabs.com/seadragon/),连名字都一摸一样哦

其实仔细看看有点类似deepzoom,不过不是用silverlight,而是用了AJAX(感觉还是Silverlight效率高啊,其实最新的Deep Zoom Composer也已经支持导出AJAX的图片了,上回就说等有时间写写Deep Zoom Composer,看来还得下次再写了… )

看图看效果:

image image

详细示例见:http://www.asp.net/AJAX/AjaxControlToolkit/Samples/Seadragon/Seadragon.aspx

 

 

不多说了,有兴趣的自己下载看看吧:

下载地址:http://ajaxcontroltoolkit.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=33804

 

示例和教程:

 

就废话这么多吧…

Read Full Post »