ASP.NET MVC Paste to clipboard

2019-08-10 00:35发布

I have a ASP.NET MVC 4 app.

I want to copy a text(from PDF) CTRL+C and paste it as parameter in a method from a controller.

My webgrid has column with an ActionLink

grid.Column(" ", " ", format: @<a href="@Url.Action("Clipboard", "People", new { cbdata = window.clipboardData.getData('Text') })">Clipboard</a>),

...

    [HttpPost]
    public ActionResult Clipboard(string cbdata) // is string ok ?
    {
        //I'm doing something with my clipboard data ..
        return View();
    }

This part is not working : window.clipboardData.getData('Text') Do I have to modify my MapRoute in Global.asax.cs ?

Q : How can I get the data from my clipboard in a method from my controller ?

1条回答
该账号已被封号
2楼-- · 2019-08-10 01:15

You want to get data from a client's clipboard to the web server?

You can't. Security is an issue. What if someone had their credit card details saved in their clipboard from a previous copy!

The only way to do that is to ask the user to explicitly paste it into a text control and send it in a form..

查看更多
登录 后发表回答