usercontrol .ascx文件 [英] usercontrol .ascx file

查看:77
本文介绍了usercontrol .ascx文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在vs2005中的default.aspx中使用.ascx用户控件?

how to use the .ascx user control in default.aspx in vs2005?

推荐答案

最简单的方法是通过简单地拖动将控件添加到网页从解决方案资源管理器到设计视图中的网页.将用户控件添加到页面后,您可以在设计"视图中查看控件的外观.如果切换到源"视图,则可以看到Visual Studio添加到页面的标记信息

也可以通过执行以下两项操作来手动完成此操作:
在Page指令之后的aspx页面中添加以下行:

The easiest way is to add a user control to a webpage by simply dragging it from Solution Explorer to a webpage in Design view. When you add the user control to a page, you can see the control’s visual makeup in Design view. If you switch to Source view, you can see the markup information that Visual Studio added to your page

It can also be done manually by doing two things:
Add the following line in the aspx page just after the Page directive:

<%@ Register src="UserControl.ascx" tagname="UserControl"

tagprefix="uc1" %>



然后,您可以像其他任何aspnet控件一样开始使用form标记内的控件,如下所示:



Then you can start using the control within the form tag like any other aspnet control as shown below:

<uc1:userControl ID="userControl1" runat="server"
someTypeProperty="Home" />



请通过此msdn链接获取更多信息, http://msdn.microsoft.com/en-us/library /sbz9etab.aspx [ ^ ]
希望对您有所帮助.



Please go through this msdn link for more information http://msdn.microsoft.com/en-us/library/sbz9etab.aspx[^]
Hope this helps.


按照下面链接中提到的教程进行操作.它具有有关.net中用户控件用法的逐步指南.

链接 [
Follow the tutorials mentioned in below link. It have step by step guide on user control usage in .net

Link [^]


这篇关于usercontrol .ascx文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆