How to retrieve custom html attributes not belonging to the control RRS feed

  • Question

  • User-406224885 posted


     I was wondering if there is any way of retrieveing custrom html attributes assigned to a control, but that do not match any property. For example, let's say y create a label like:

    string str=" <asp:Label ID="Label1" runat="server" localizationResourceKey="KEY"/>";

    Control ctrl=Page.ParseControl(str);

     Is there any way to get the value for the localizationResourceKey programaticaly if I have access to the ctrl variable? I need that as a workaroung for my previous post about the implicit localization of dynamic controls...

     If I get to retrieve the localizationResourceKey, then I can apply the localization programaticaly, as the meta:resourcekey does not work with ParseControl.



    Thursday, November 15, 2007 9:16 AM


  • User-406224885 posted

     Hi! I finally managed myself to guess how. The WebControl and HtmlControl have a Property called Attributes which stores those attributes that do not belong to the control, so I just had to cast the Control class to either WebControl or HtmlControl, the appropriate one. And that's all!

     I'm posting the solution sot hat anyone else can benefit from it!




    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, November 15, 2007 4:14 PM