开发者

Adding custom attribute to a class defined in asp.net inline code

开发者 https://www.devze.com 2023-03-14 14:09 出处:网络
I have an asp.net page that is alrea开发者_开发百科dy 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.

I have an asp.net page that is alrea开发者_开发百科dy 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?


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

0

精彩评论

暂无评论...
验证码 换一张
取 消