custom web controls and conversion to inline code

Discussion in 'ASP .Net Web Controls' started by Lefty, Jun 16, 2005.

  1. Lefty

    Lefty Guest

    Our client wanted delivery of the code using inline scripting, but for
    obvious reasons, we developed the ASP.NET 1.1 app using codebehind. We have
    an issue now when trying to convert the codebehind code to an inline format.

    The control fires a custom event (to pass detailed error info up the
    containing page, should they choose to implement a listener for the event).
    Using C# the custom control is doing something like this:

    ==============
    public delegate void UserControlEventHandler(object sender,
    ThinData.Common.UserControlEventArgs e);

    public event UserControlEventHandler UserControlError;
    ==============

    the parent page consuming the control was doing this:

    ==============
    PersInfo1.UserControlError += new
    ClientName.RegistrationUserControls.PersonalInformationForm.UserControlEventHandler(Generic_UserControlError);
    ==============

    The above works fine using codebehind.

    My problem is that within the containing page, when it is converted to
    inline script, the namespace and name:
    ClientName.RegistrationUserControls.PersonalInformationForm...

    cannot be resolved properly. The error is "missing assembly reference?"

    How should I be doing this so I can wire up the event in the parent page
    properly?

    Thanks.
     
    Lefty, Jun 16, 2005
    #1
    1. Advertising

  2. Lefty

    Brock Allen Guest

    Add a Reference directive to your page:

    <%@ Reference Control="Foo.ascx" %>

    -Brock
    DevelopMentor
    http://staff.develop.com/ballen



    > Our client wanted delivery of the code using inline scripting, but for
    > obvious reasons, we developed the ASP.NET 1.1 app using codebehind.
    > We have an issue now when trying to convert the codebehind code to an
    > inline format.
    >
    > The control fires a custom event (to pass detailed error info up the
    > containing page, should they choose to implement a listener for the
    > event). Using C# the custom control is doing something like this:
    >
    > ==============
    > public delegate void UserControlEventHandler(object sender,
    > ThinData.Common.UserControlEventArgs e);
    > public event UserControlEventHandler UserControlError; ==============
    >
    > the parent page consuming the control was doing this:
    >
    > ==============
    >
    > PersInfo1.UserControlError += new
    >
    > ClientName.RegistrationUserControls.PersonalInformationForm.UserContro
    > lEventHandler(Generic_UserControlError);
    >
    > ==============
    >
    > The above works fine using codebehind.
    >
    > My problem is that within the containing page, when it is converted to
    > inline script, the namespace and name:
    > ClientName.RegistrationUserControls.PersonalInformationForm...
    >
    > cannot be resolved properly. The error is "missing assembly
    > reference?"
    >
    > How should I be doing this so I can wire up the event in the parent
    > page properly?
    >
    > Thanks.
    >
     
    Brock Allen, Jun 16, 2005
    #2
    1. Advertising

  3. Lefty

    Lefty Guest

    thanks for the reply.

    I tried your suggestion earlier to no avail. I have since found out that
    when converting codebehind pages to inline (the namespace and the class
    definition are removed when moving the code to a script block within the aspx
    page) and that is why I could not use the namespace naming convention.

    I learned that if I used the default namespace notation provided by ASP.NET
    for inline pages:

    ASP.ControlName_ascx.EventHandler

    That the code would then work as intended.

    I don't much like having to change this code however, in order to convert
    the pages to inline script.

    Is there a way to retain the use of namespaces when code is converted to
    inline from codebehind?


    "Brock Allen" wrote:

    > Add a Reference directive to your page:
    >
    > <%@ Reference Control="Foo.ascx" %>
    >
    > -Brock
    > DevelopMentor
    > http://staff.develop.com/ballen
    >
    >
    >
    > > Our client wanted delivery of the code using inline scripting, but for
    > > obvious reasons, we developed the ASP.NET 1.1 app using codebehind.
    > > We have an issue now when trying to convert the codebehind code to an
    > > inline format.
    > >
    > > The control fires a custom event (to pass detailed error info up the
    > > containing page, should they choose to implement a listener for the
    > > event). Using C# the custom control is doing something like this:
    > >
    > > ==============
    > > public delegate void UserControlEventHandler(object sender,
    > > ThinData.Common.UserControlEventArgs e);
    > > public event UserControlEventHandler UserControlError; ==============
    > >
    > > the parent page consuming the control was doing this:
    > >
    > > ==============
    > >
    > > PersInfo1.UserControlError += new
    > >
    > > ClientName.RegistrationUserControls.PersonalInformationForm.UserContro
    > > lEventHandler(Generic_UserControlError);
    > >
    > > ==============
    > >
    > > The above works fine using codebehind.
    > >
    > > My problem is that within the containing page, when it is converted to
    > > inline script, the namespace and name:
    > > ClientName.RegistrationUserControls.PersonalInformationForm...
    > >
    > > cannot be resolved properly. The error is "missing assembly
    > > reference?"
    > >
    > > How should I be doing this so I can wire up the event in the parent
    > > page properly?
    > >
    > > Thanks.
    > >

    >
    >
    >
    >
     
    Lefty, Jun 17, 2005
    #3
  4. Lefty

    Brock Allen Guest

    > Is there a way to retain the use of namespaces when code is converted
    > to inline from codebehind?


    The primary problem is that VS.NET does things its way and ASP.NET does them
    another. This is less the case in VS.NET 2005, since the group at Microsoft
    is now one (or whole, if you want to think of it that way).

    -Brock
    DevelopMentor
    http://staff.develop.com/ballen
     
    Brock Allen, Jun 17, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Axel Dahmen
    Replies:
    1
    Views:
    542
    Teemu Keiski
    Nov 12, 2003
  2. Sean
    Replies:
    4
    Views:
    693
    Rolf Magnus
    Apr 30, 2006
  3. Rahul
    Replies:
    3
    Views:
    479
    James Kanze
    Feb 28, 2008
  4. Lefty

    custom web controls and conversion to inline code

    Lefty, Jun 16, 2005, in forum: ASP .Net Building Controls
    Replies:
    2
    Views:
    121
    Sergey Polyakov
    Jun 17, 2005
  5. jahles
    Replies:
    2
    Views:
    176
    Teemu Keiski
    Aug 28, 2003
Loading...

Share This Page