Loading ...
Sorry, an error occurred while loading the content.

1649Re: .NET-style components and development

Expand Messages
  • Josh Chamas
    Mar 15, 2004
      John Drago wrote:
      >
      > What I want to do would look something like so:
      > ---------------------------------------------------------------
      > [listbox.asp]
      >
      > <asp:listbox id="list1">
      > <asp:listitem>Select One</asp:listitem>
      > </asp:listbox>
      >
      > <%
      > # Dynamically add items to the list before it's rendered:
      > $Page->list1->Items->add(
      > asp::listitem->new( Value => "1", Text => "Blue" ) );
      > $Page->list1->Items->add(
      > asp::listitem->new( Value => "2", Text => "Red" ) );
      >
      > # or, iterate through items within the listbox:
      > foreach my $item ( $Page->list1->Items )
      > {
      > if( $item->Value == 1 )
      > {
      > $item->Text = "Blue [this is my favorite...isn't it yours?]";
      > }# end if()
      > }# end foreach()
      >
      > %>
      > ---------------------------------------------------------------
      >
      > Something tells me that this isn't too far away from what we already
      > have with Apache::ASP...that with some extra methods inherited from a
      > package subclassed by asp::listbox and asp::listitem, it is 100%
      > possible.
      >
      > I would need some help with where to bless the $Page object into the
      > namespace the ASP pages are executed in.
      >

      If you set up a $List object in global.asa, it will be seen in includes
      and scripts, but not in the scope of the XMLSubs packages. So you might
      create it in the main package to reference from like this:

      # global.asa
      use vars qw($List);
      sub Script_OnStart {
      $List = $main::List = List->new();
      }
      sub Script_OnEnd {
      $List->can('DESTROY') && $List->DESTROY;
      $List = $main::List = undef;
      }

      Then in the script, you can:

      <%
      $List->->add('list1',
      ListItem->new( Value => "1", Text => "Blue" )
      );
      %>

      And then you can:

      <asp:listbox id="list1">
      <asp:listitem>Select One</asp:listitem>
      </asp:listbox>

      And have XMLSubs defined to handle asp:listbox & asp:listitem properly,
      looking at the $main::List object.

      If you really want to build objects through code though, you might check
      out CGI.pm, which has plenty of methods for doing exactly this. Output
      from a CGI.pm object should be compatible with Apache::ASP.

      > Apache::ASP does *almost* everything I want it to do, and this kind of
      > extension would make it a lot more powerful in my opinion.

      What is the extension in particular that you are looking for?
      Is there something particular about <asp:listbox /> handling that you
      like in ASP.NET that you want implemented as is? Particularly what
      features of ASP.NET do you think should make it into Apache::ASP ?

      Regards,

      Josh

      ________________________________________________________________________
      Josh Chamas, Founder | NodeWorks - http://www.nodeworks.com
      Chamas Enterprises Inc. | NodeWorks Directory - http://dir.nodeworks.com
      http://www.chamas.com | Apache::ASP - http://www.apache-asp.org




      ---------------------------------------------------------------------
      To unsubscribe, e-mail: asp-unsubscribe@...
      For additional commands, e-mail: asp-help@...
    • Show all 13 messages in this topic