在我看来,C# 将 link 复制到剪贴板
C# copying link to clipboard in my view
我正在尝试将 link 复制到我认为的剪贴板。
尝试了几个不同的帖子,我在这里。
是否必须在我的模型中设置?
我想将此代码生成的 link 复制到我的剪贴板
@(Url.Action<MillerElectricLearn.Areas.Instructor.Controllers.UserController>(c => c.New())
我的观点
@model User_Index_ViewModel
@{
AddBreadcrumb<HomeController>(c => c.Index(), "Home");
}
<div><a href="@(Url.Action<MillerElectricLearn.Areas.Instructor.Controllers.UserController>(c => c.New()))" class="organizationRegistration btn btn-default">Create Learner</a></div>
Clipboard.SetText(link, @(Url.Action<MillerElectricLearn.Areas.Instructor.Controllers.UserController>(c => c.New()))
我的模型
public class User_Index_ViewModel :ViewModel
{
// public User_Index_ViewModel(IDependencyResolver dependencyResolver, IRuntimeContextProvider contextProvider)
public User_Index_ViewModel(IDependencyResolver dependencyResolver, IRuntimeContextProvider contextProvider)
: base(dependencyResolver.Get<IDataAccessService>())
{
this.ContextProvider = contextProvider;
this.DependencyResolver = dependencyResolver;
}
public IRuntimeContextProvider ContextProvider { get; set; }
public IDependencyResolver DependencyResolver { get; set; }
public List<User> TheInstructorsLearners { get; set; }
public User CurrentUser { get; set; }
protected override void PrepareForView()
{
base.PrepareForView();
CurrentUser = DataAccessService.GetUser(ContextProvider.GetContext().User);
this.TheInstructorsLearners = DataAccessService.Find<User>(x => x.OrganizationId == CurrentUser.OrganizationId).ToList();
}
}
Clipboard.SetText Method 来自 System.Windows.Forms(在 System.Windows.Forms.dll 中)。
Windows Forms 和 ASP.NET MVC 是完全不同的技术。
如果您尝试在客户端复制某些内容,那么您可以尝试使用 javascript 或 flash。
看看这个问题How do I copy to the clipboard in JavaScript?
如果您正在尝试调试您的操作 URL,您可以尝试 Debug.WriteLine:
@{System.Diagnostics.Debug.WriteLine( Url.Action<MillerElectricLearn.Areas.Instructor.Controllers.UserController>(c => c.New())) );}
我正在尝试将 link 复制到我认为的剪贴板。
尝试了几个不同的帖子,我在这里。 是否必须在我的模型中设置?
我想将此代码生成的 link 复制到我的剪贴板
@(Url.Action<MillerElectricLearn.Areas.Instructor.Controllers.UserController>(c => c.New())
我的观点
@model User_Index_ViewModel
@{
AddBreadcrumb<HomeController>(c => c.Index(), "Home");
}
<div><a href="@(Url.Action<MillerElectricLearn.Areas.Instructor.Controllers.UserController>(c => c.New()))" class="organizationRegistration btn btn-default">Create Learner</a></div>
Clipboard.SetText(link, @(Url.Action<MillerElectricLearn.Areas.Instructor.Controllers.UserController>(c => c.New()))
我的模型
public class User_Index_ViewModel :ViewModel
{
// public User_Index_ViewModel(IDependencyResolver dependencyResolver, IRuntimeContextProvider contextProvider)
public User_Index_ViewModel(IDependencyResolver dependencyResolver, IRuntimeContextProvider contextProvider)
: base(dependencyResolver.Get<IDataAccessService>())
{
this.ContextProvider = contextProvider;
this.DependencyResolver = dependencyResolver;
}
public IRuntimeContextProvider ContextProvider { get; set; }
public IDependencyResolver DependencyResolver { get; set; }
public List<User> TheInstructorsLearners { get; set; }
public User CurrentUser { get; set; }
protected override void PrepareForView()
{
base.PrepareForView();
CurrentUser = DataAccessService.GetUser(ContextProvider.GetContext().User);
this.TheInstructorsLearners = DataAccessService.Find<User>(x => x.OrganizationId == CurrentUser.OrganizationId).ToList();
}
}
Clipboard.SetText Method 来自 System.Windows.Forms(在 System.Windows.Forms.dll 中)。
Windows Forms 和 ASP.NET MVC 是完全不同的技术。
如果您尝试在客户端复制某些内容,那么您可以尝试使用 javascript 或 flash。
看看这个问题How do I copy to the clipboard in JavaScript?
如果您正在尝试调试您的操作 URL,您可以尝试 Debug.WriteLine:
@{System.Diagnostics.Debug.WriteLine( Url.Action<MillerElectricLearn.Areas.Instructor.Controllers.UserController>(c => c.New())) );}