将自定义属性添加到 asp.net 内联代码中定义的类
我有一个已经用内联 vb.net 编写的 asp.net 页面。我真正需要做的就是向类添加一个自定义属性,但它不知道在哪里添加它。
<%@ Page Language="vb" %>
<script runat="server">
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
...
End Sub
</script>
在检查页面对象属性的代码中,我可以看到 page.GetType.fullName = "ASP.test_aspx" ,页面文件名为 test.aspx。
这可能吗?
I have an asp.net page that is already written with inline vb.net. All I really need to do is add a custom attribute to the class but it can't figure out where to add it.
<%@ Page Language="vb" %>
<script runat="server">
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
...
End Sub
</script>
In the code that checks for the attribute on the page object, I can see the page.GetType.fullName = "ASP.test_aspx" with the page filename as test.aspx.
Is this possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为您不能直接执行此操作,因为该类是自动生成的,并且我很确定编译器没有添加属性的规定。就我个人而言,我会使用单独的类文件重写页面(无论如何我总是更喜欢这样做)。如果这不是一个选项,根据属性和使用它的内容,您可以创建一个继承自 Page 的类,并在 @Page 指令中继承该属性
I don't think you can do this directly as the class is autogenerated and I'm pretty sure that the compiler doesn't have provision for adding attributes. Personally, I'd rewrite the page with a separate class file (I always prefer to do that anyway). If that isn't an option, depending on the attribute and what is using it, you may be able to create a class that inherits from Page with the attribute on and inherit from in the the @Page directive