访问 ASP.Net 用户控件
嘿伙计们,
我创建了一个 CustomFileUpload
类,它是从原始 FileUpload
类继承的,我不得不说它实际上不是一个 UserControl
它是一个简单的类,如下所示,
using System;
using System.Web;
public class CustomFileUpload : System.Web.UI.WebControls.FileUpload
{
public string Directory { get; set; }
}
我需要知道如何在页面中使用该控件,当我们创建用户控件时,可能类似于 <@Registe ...
。
Hey guys,
I've created a CustomFileUpload
class which is inherited from the original FileUpload
class, I'm gonna have to say it's not actually a UserControl
it's a simple class which can be seen below
using System;
using System.Web;
public class CustomFileUpload : System.Web.UI.WebControls.FileUpload
{
public string Directory { get; set; }
}
I need to know how I can use the control in my page, maybe something like <@Registe ...
when we create a usercontrol.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这称为自定义服务器控件。您可以阅读有关它们的深入演练。您需要将服务器控件驻留在与您的项目分开的程序集中,然后将该程序集引用到您的项目中。
将控件放在页面上要使用的语法是:
然后您可以引用该控件:
执行此操作的一个简单方法是将控件添加到工具箱。然后您可以将控件从工具箱拖到任何页面上。注册表将自动创建。将控件添加到工具箱
This is called a custom server control. You can read an indepth walkthrough about them. You will need to have the server control reside in an assembly that is separate from your project and then reference the assembly into your project.
The syntax you want to use to put the control on the page is:
Then you can reference the control:
An easy way to do this is to add the control to your toolbox. Then you can drag the control from the toolbox onto any page. The Register will be created automatically. To add the control to the toolbox
您可以执行以下操作:
您也可以在配置级别执行此操作:
然后在您的页面中使用:
You can do:
You can also do this at the config level:
Then use in your page:
您需要将您的类放入命名空间中并像这样注册它
然后您可以使用这样的控件
http://msdn.microsoft.com/en-us/library/c76dd5k1(v=VS.100).aspx
You need to put your class in a Namespace and register it like this
Then you can use the control like this
http://msdn.microsoft.com/en-us/library/c76dd5k1(v=VS.100).aspx