求助c# web程序 客户端如何读取剪贴版里的内容这个里面要引用什么类,才能调用Clipboard
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.Runtime.InteropServices.ComTypes;
public partial class kj_TestKJ : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (Clipboard.GetDataObject() != null)//判断剪贴板上面有没有东西,有则继续下面的语句
{
IDataObject obj = Clipboard.GetDataObject();//获取剪贴板上的信息
if (obj.GetDataPresent(DataFormats.Text)) //判断剪贴板上面是不是text文本,即字符
{
this.Label1.Text += (obj.GetData(DataFormats.Text)).ToString();//因为GetDataPresent这方法取出来的是一个object类型,因此要转换
}
} }
}
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.Runtime.InteropServices.ComTypes;
public partial class kj_TestKJ : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (Clipboard.GetDataObject() != null)//判断剪贴板上面有没有东西,有则继续下面的语句
{
IDataObject obj = Clipboard.GetDataObject();//获取剪贴板上的信息
if (obj.GetDataPresent(DataFormats.Text)) //判断剪贴板上面是不是text文本,即字符
{
this.Label1.Text += (obj.GetData(DataFormats.Text)).ToString();//因为GetDataPresent这方法取出来的是一个object类型,因此要转换
}
} }
}
UP
ASP.NET是运行在服务器的,无法读取客户端资源
而HTML又没有实现读取本地的功能,如果有的话安全就全成问题了
只有用客户端脚本做读取本地化资源了
this.richTextBox1.Paste();
这样可以读啊!