使用用户控件在同一文件夹中的页面

编程入门 行业动态 更新时间:2024-10-17 05:01:48
本文介绍了使用用户控件在同一文件夹中的页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我在ASP.NET页面2的运行时间得到这个消息:

I get this message at runtime of ASP.NET 2 page :

该页面'MyFolder中/ blabla.aspx'不能使用用户控件MyFolder中/ MyControl.ascx',因为它是注册在web.config中,住在同一目录页。

The page 'MyFolder/blabla.aspx' cannot use the user control 'MyFolder/MyControl.ascx', because it is registered in web.config and lives in the same directory as the page.

当然,我可以将它们分开到2个不同的文件夹,从而解决问题,但问题是:

Of course I can separate them to 2 different folders and thus solve the problem, but the question is :

WTF!?!?!为什么我不能把它们放在同一个文件夹!他们为什么不能好..相处!?! :)

WTF !?!?! Why I can't put them in the same folder ?! Why can't they all .. get along !?! :)

感谢

推荐答案

这限制是设计由于内部设计考虑重新:性能

This limitation is by design due to an internal design consideration re: performance.

请参阅这里进一步的信息。

备注

标签prefixInfo类允许您以编程方式访问和  修改存储在配置文件标签也即preFIX信息。它  提供相同的功能的ASP.NET @ 注册  指示。标签prefixes ASP.NET中的一个相关联的空间  集和命名空间中必须包含自定义控件  和用户控件才能正常工作。标签prefixInfo对象存储  作为标签prefixCollection成员对象。该  标签prefixCollection 类允许您以编程方式访问  并修改控制在页第的一部分  配置文件。

The TagPrefixInfo class allows you to programmatically access and modify tag-prefix information stored in a configuration file. It provides the same functionality as the ASP.NET @Register directive. Tag prefixes associate a "namespace" in ASP.NET to the assemblies and namespaces that must be included for custom controls and user controls to work properly. TagPrefixInfo objects are stored as members of a TagPrefixCollection object. The TagPrefixCollection class allows you to programmatically access and modify the controls subsection of the pages section of a configuration file.

标签prefixInfo对象是使用添加到集合中的添加  元素并指定在标签preFIX 属性值一起  与其他相关属性的值。其他要求  信息变化的基础上的一种控制,你将与使用  指定标签preFIX:

TagPrefixInfo objects are added to the collection using the add element and specifying a value for the tagPrefix attribute along with values for other relevant attributes. The other required information varies based on the kind of control you will use with the specified tag prefix:

      
  • 如果它是一个用户控件,你必须定义标签preFIX ,的标签名和的来源属性。
  •   
  • 如果它是一个自定义的控制,你必须定义标签preFIX ,命名空间和的大会属性。该大会  如果控制在应用code未必需的属性  目录。同样的标签preFIX 值可以用来映射到多个  组件或命名空间。
  •   
  • If it is a user control, you must define the TagPrefix, TagName, and Source properties.
  • If it is a custom control, you must define the TagPrefix, Namespace, and Assembly properties. The Assembly property is not required if the control is in the application code directory. The same tagPrefix value can be used to map to multiple assemblies or namespaces.

注意:当指定了源,用户控件本身不能在同一个目录页面。如果是,你得到一个运行时  错误,当您尝试加载页面。

Note When a source is specified, the user control itself must not be in the same directory as the page. If it is, you get a run-time error when you attempt to load the page.

更多推荐

使用用户控件在同一文件夹中的页面

本文发布于:2023-11-01 13:03:26,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1549404.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:控件   页面   文件   用户   夹中

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!