Using inline-code with code behind.

Discussion in 'ASP .Net' started by Anders M, Apr 28, 2005.

  1. Anders M

    Anders M Guest

    I'm trying to use Inline-code to call Page_load, Page_Init or Page_PreRender
    methods.

    I've also got a code behind c#-file.

    I can define inline methods for buttons and so on...that works fine. But
    when I try to call Page_load, Page_Init or Page_PreRender methods it doesn't
    work.

    Non of the methods get's triggered !?

    How can I solve this problem with combining code behind and inline-code?
    I just need an action to call my own defined dll-call, it must be done in
    inlin -code!

    Regards
    /Anders
     
    Anders M, Apr 28, 2005
    #1
    1. Advertising

  2. Anders M

    Karl Seguin Guest

    Anders:
    I can't see why you HAVE to use both..that doesn't really make sense to me.
    Why not just create a function called "Initialize()" in codebehind which you
    can call in the inline page_load event?

    Karl

    --
    MY ASP.Net tutorials
    http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
    http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
    come!)


    "Anders M" <> wrote in message
    news:...
    > I'm trying to use Inline-code to call Page_load, Page_Init or
    > Page_PreRender
    > methods.
    >
    > I've also got a code behind c#-file.
    >
    > I can define inline methods for buttons and so on...that works fine. But
    > when I try to call Page_load, Page_Init or Page_PreRender methods it
    > doesn't
    > work.
    >
    > Non of the methods get's triggered !?
    >
    > How can I solve this problem with combining code behind and inline-code?
    > I just need an action to call my own defined dll-call, it must be done in
    > inlin -code!
    >
    > Regards
    > /Anders
    >
    >
    >
    >
    >
    >
    >
     
    Karl Seguin, Apr 28, 2005
    #2
    1. Advertising

  3. Anders M

    Anders M Guest

    Because I don't have access to the code behind file! I'm modifying an
    ..ascx-file that's using several dll's made third part developers.

    Maybe I can make a dll and override Page_Load event?
    /Anders



    "Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
    skrev i meddelandet news:uzO9%23N%...
    > Anders:
    > I can't see why you HAVE to use both..that doesn't really make sense to

    me.
    > Why not just create a function called "Initialize()" in codebehind which

    you
    > can call in the inline page_load event?
    >
    > Karl
    >
    > --
    > MY ASP.Net tutorials
    > http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
    > http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
    > come!)
    >
    >
    > "Anders M" <> wrote in message
    > news:...
    > > I'm trying to use Inline-code to call Page_load, Page_Init or
    > > Page_PreRender
    > > methods.
    > >
    > > I've also got a code behind c#-file.
    > >
    > > I can define inline methods for buttons and so on...that works fine. But
    > > when I try to call Page_load, Page_Init or Page_PreRender methods it
    > > doesn't
    > > work.
    > >
    > > Non of the methods get's triggered !?
    > >
    > > How can I solve this problem with combining code behind and inline-code?
    > > I just need an action to call my own defined dll-call, it must be done

    in
    > > inlin -code!
    > >
    > > Regards
    > > /Anders
    > >
    > >
    > >
    > >
    > >
    > >
    > >

    >
    >
     
    Anders M, Apr 28, 2005
    #3
  4. Anders M

    Karl Seguin Guest

    I guess I still don't understand..

    Given the following inline:

    <script language="C#" runat="server">
    void Page_Load(object sender, EventArgs e){
    Response.Write("1");
    }
    </script>

    and the following codebehind:

    private void Page_Load(object sender, EventArgs e)
    {
    Response.Write("2");
    }

    both events will fire....

    Karl

    --
    MY ASP.Net tutorials
    http://www.openmymind.net/ - New and Improved (yes, the popup is
    annoying)
    http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
    come!)
    "Anders M" <> wrote in message
    news:Oc4Acm%...
    > Because I don't have access to the code behind file! I'm modifying an
    > .ascx-file that's using several dll's made third part developers.
    >
    > Maybe I can make a dll and override Page_Load event?
    > /Anders
    >
    >
    >
    > "Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
    > skrev i meddelandet news:uzO9%23N%...
    >> Anders:
    >> I can't see why you HAVE to use both..that doesn't really make sense to

    > me.
    >> Why not just create a function called "Initialize()" in codebehind which

    > you
    >> can call in the inline page_load event?
    >>
    >> Karl
    >>
    >> --
    >> MY ASP.Net tutorials
    >> http://www.openmymind.net/ - New and Improved (yes, the popup is
    >> annoying)
    >> http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
    >> come!)
    >>
    >>
    >> "Anders M" <> wrote in message
    >> news:...
    >> > I'm trying to use Inline-code to call Page_load, Page_Init or
    >> > Page_PreRender
    >> > methods.
    >> >
    >> > I've also got a code behind c#-file.
    >> >
    >> > I can define inline methods for buttons and so on...that works fine.
    >> > But
    >> > when I try to call Page_load, Page_Init or Page_PreRender methods it
    >> > doesn't
    >> > work.
    >> >
    >> > Non of the methods get's triggered !?
    >> >
    >> > How can I solve this problem with combining code behind and
    >> > inline-code?
    >> > I just need an action to call my own defined dll-call, it must be done

    > in
    >> > inlin -code!
    >> >
    >> > Regards
    >> > /Anders
    >> >
    >> >
    >> >
    >> >
    >> >
    >> >
    >> >

    >>
    >>

    >
    >
     
    Karl Seguin, Apr 28, 2005
    #4
  5. Anders M

    Anders M Guest

    For me the inline Page_Load don't fire!
    If I remove <@Page Language="c#" codebehind="WebForm1.aspx.cs".......> The
    Inline code fires!

    Else only the codebehind code.

    /Anders




    "Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
    skrev i meddelandet news:uyMrsN$...
    > I guess I still don't understand..
    >
    > Given the following inline:
    >
    > <script language="C#" runat="server">
    > void Page_Load(object sender, EventArgs e){
    > Response.Write("1");
    > }
    > </script>
    >
    > and the following codebehind:
    >
    > private void Page_Load(object sender, EventArgs e)
    > {
    > Response.Write("2");
    > }
    >
    > both events will fire....
    >
    > Karl
    >
    > --
    > MY ASP.Net tutorials
    > http://www.openmymind.net/ - New and Improved (yes, the popup is
    > annoying)
    > http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
    > come!)
    > "Anders M" <> wrote in message
    > news:Oc4Acm%...
    > > Because I don't have access to the code behind file! I'm modifying an
    > > .ascx-file that's using several dll's made third part developers.
    > >
    > > Maybe I can make a dll and override Page_Load event?
    > > /Anders
    > >
    > >
    > >
    > > "Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
    > > skrev i meddelandet news:uzO9%23N%...
    > >> Anders:
    > >> I can't see why you HAVE to use both..that doesn't really make sense to

    > > me.
    > >> Why not just create a function called "Initialize()" in codebehind

    which
    > > you
    > >> can call in the inline page_load event?
    > >>
    > >> Karl
    > >>
    > >> --
    > >> MY ASP.Net tutorials
    > >> http://www.openmymind.net/ - New and Improved (yes, the popup is
    > >> annoying)
    > >> http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
    > >> come!)
    > >>
    > >>
    > >> "Anders M" <> wrote in message
    > >> news:...
    > >> > I'm trying to use Inline-code to call Page_load, Page_Init or
    > >> > Page_PreRender
    > >> > methods.
    > >> >
    > >> > I've also got a code behind c#-file.
    > >> >
    > >> > I can define inline methods for buttons and so on...that works fine.
    > >> > But
    > >> > when I try to call Page_load, Page_Init or Page_PreRender methods it
    > >> > doesn't
    > >> > work.
    > >> >
    > >> > Non of the methods get's triggered !?
    > >> >
    > >> > How can I solve this problem with combining code behind and
    > >> > inline-code?
    > >> > I just need an action to call my own defined dll-call, it must be

    done
    > > in
    > >> > inlin -code!
    > >> >
    > >> > Regards
    > >> > /Anders
    > >> >
    > >> >
    > >> >
    > >> >
    > >> >
    > >> >
    > >> >
    > >>
    > >>

    > >
    > >

    >
    >
     
    Anders M, Apr 28, 2005
    #5
  6. Anders M

    Anders M Guest

    Hmmmm...
    It works when I remove AutoEventWireup="false" from the aspx-page??

    Anyone knows why?
    /Anders



    "Anders M" <> skrev i meddelandet
    news:%233ozjU$...
    >
    >
    > For me the inline Page_Load don't fire!
    > If I remove <@Page Language="c#" codebehind="WebForm1.aspx.cs".......> The
    > Inline code fires!
    >
    > Else only the codebehind code.
    >
    > /Anders
    >
    >
    >
    >
    > "Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
    > skrev i meddelandet news:uyMrsN$...
    > > I guess I still don't understand..
    > >
    > > Given the following inline:
    > >
    > > <script language="C#" runat="server">
    > > void Page_Load(object sender, EventArgs e){
    > > Response.Write("1");
    > > }
    > > </script>
    > >
    > > and the following codebehind:
    > >
    > > private void Page_Load(object sender, EventArgs e)
    > > {
    > > Response.Write("2");
    > > }
    > >
    > > both events will fire....
    > >
    > > Karl
    > >
    > > --
    > > MY ASP.Net tutorials
    > > http://www.openmymind.net/ - New and Improved (yes, the popup is
    > > annoying)
    > > http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
    > > come!)
    > > "Anders M" <> wrote in message
    > > news:Oc4Acm%...
    > > > Because I don't have access to the code behind file! I'm modifying an
    > > > .ascx-file that's using several dll's made third part developers.
    > > >
    > > > Maybe I can make a dll and override Page_Load event?
    > > > /Anders
    > > >
    > > >
    > > >
    > > > "Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME

    net>
    > > > skrev i meddelandet news:uzO9%23N%...
    > > >> Anders:
    > > >> I can't see why you HAVE to use both..that doesn't really make sense

    to
    > > > me.
    > > >> Why not just create a function called "Initialize()" in codebehind

    > which
    > > > you
    > > >> can call in the inline page_load event?
    > > >>
    > > >> Karl
    > > >>
    > > >> --
    > > >> MY ASP.Net tutorials
    > > >> http://www.openmymind.net/ - New and Improved (yes, the popup is
    > > >> annoying)
    > > >> http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more

    to
    > > >> come!)
    > > >>
    > > >>
    > > >> "Anders M" <> wrote in message
    > > >> news:...
    > > >> > I'm trying to use Inline-code to call Page_load, Page_Init or
    > > >> > Page_PreRender
    > > >> > methods.
    > > >> >
    > > >> > I've also got a code behind c#-file.
    > > >> >
    > > >> > I can define inline methods for buttons and so on...that works

    fine.
    > > >> > But
    > > >> > when I try to call Page_load, Page_Init or Page_PreRender methods

    it
    > > >> > doesn't
    > > >> > work.
    > > >> >
    > > >> > Non of the methods get's triggered !?
    > > >> >
    > > >> > How can I solve this problem with combining code behind and
    > > >> > inline-code?
    > > >> > I just need an action to call my own defined dll-call, it must be

    > done
    > > > in
    > > >> > inlin -code!
    > > >> >
    > > >> > Regards
    > > >> > /Anders
    > > >> >
    > > >> >
    > > >> >
    > > >> >
    > > >> >
    > > >> >
    > > >> >
    > > >>
    > > >>
    > > >
    > > >

    > >
    > >

    >
    >
     
    Anders M, Apr 28, 2005
    #6
  7. Anders M

    Karl Seguin Guest

    Yes, AutoEventWireUp automatically wires events based on their name...so it
    seems a function Page_Load and automatically hooks it into the OnLoage event
    of the page...inline works like that (and only like that)....

    karl

    --
    MY ASP.Net tutorials
    http://www.openmymind.net/ - New and Improved (yes, the popup is
    annoying)
    http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
    come!)
    "Anders M" <> wrote in message
    news:...
    > Hmmmm...
    > It works when I remove AutoEventWireup="false" from the aspx-page??
    >
    > Anyone knows why?
    > /Anders
    >
    >
    >
    > "Anders M" <> skrev i meddelandet
    > news:%233ozjU$...
    >>
    >>
    >> For me the inline Page_Load don't fire!
    >> If I remove <@Page Language="c#" codebehind="WebForm1.aspx.cs".......>
    >> The
    >> Inline code fires!
    >>
    >> Else only the codebehind code.
    >>
    >> /Anders
    >>
    >>
    >>
    >>
    >> "Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
    >> skrev i meddelandet news:uyMrsN$...
    >> > I guess I still don't understand..
    >> >
    >> > Given the following inline:
    >> >
    >> > <script language="C#" runat="server">
    >> > void Page_Load(object sender, EventArgs e){
    >> > Response.Write("1");
    >> > }
    >> > </script>
    >> >
    >> > and the following codebehind:
    >> >
    >> > private void Page_Load(object sender, EventArgs e)
    >> > {
    >> > Response.Write("2");
    >> > }
    >> >
    >> > both events will fire....
    >> >
    >> > Karl
    >> >
    >> > --
    >> > MY ASP.Net tutorials
    >> > http://www.openmymind.net/ - New and Improved (yes, the popup is
    >> > annoying)
    >> > http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
    >> > come!)
    >> > "Anders M" <> wrote in message
    >> > news:Oc4Acm%...
    >> > > Because I don't have access to the code behind file! I'm modifying an
    >> > > .ascx-file that's using several dll's made third part developers.
    >> > >
    >> > > Maybe I can make a dll and override Page_Load event?
    >> > > /Anders
    >> > >
    >> > >
    >> > >
    >> > > "Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME

    > net>
    >> > > skrev i meddelandet news:uzO9%23N%...
    >> > >> Anders:
    >> > >> I can't see why you HAVE to use both..that doesn't really make sense

    > to
    >> > > me.
    >> > >> Why not just create a function called "Initialize()" in codebehind

    >> which
    >> > > you
    >> > >> can call in the inline page_load event?
    >> > >>
    >> > >> Karl
    >> > >>
    >> > >> --
    >> > >> MY ASP.Net tutorials
    >> > >> http://www.openmymind.net/ - New and Improved (yes, the popup is
    >> > >> annoying)
    >> > >> http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more

    > to
    >> > >> come!)
    >> > >>
    >> > >>
    >> > >> "Anders M" <> wrote in message
    >> > >> news:...
    >> > >> > I'm trying to use Inline-code to call Page_load, Page_Init or
    >> > >> > Page_PreRender
    >> > >> > methods.
    >> > >> >
    >> > >> > I've also got a code behind c#-file.
    >> > >> >
    >> > >> > I can define inline methods for buttons and so on...that works

    > fine.
    >> > >> > But
    >> > >> > when I try to call Page_load, Page_Init or Page_PreRender methods

    > it
    >> > >> > doesn't
    >> > >> > work.
    >> > >> >
    >> > >> > Non of the methods get's triggered !?
    >> > >> >
    >> > >> > How can I solve this problem with combining code behind and
    >> > >> > inline-code?
    >> > >> > I just need an action to call my own defined dll-call, it must be

    >> done
    >> > > in
    >> > >> > inlin -code!
    >> > >> >
    >> > >> > Regards
    >> > >> > /Anders
    >> > >> >
    >> > >> >
    >> > >> >
    >> > >> >
    >> > >> >
    >> > >> >
    >> > >> >
    >> > >>
    >> > >>
    >> > >
    >> > >
    >> >
    >> >

    >>
    >>

    >
    >
     
    Karl Seguin, Apr 28, 2005
    #7
    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. Ben Miller [msft]

    Re: Code Behind vs. no code behind: error

    Ben Miller [msft], Jun 27, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    593
    Alphonse Giambrone
    Jun 28, 2003
  2. Mitch A

    inline code VS page behind code

    Mitch A, Nov 1, 2003, in forum: ASP .Net
    Replies:
    3
    Views:
    3,482
    Chris R. Timmons
    Nov 2, 2003
  3. Kamal Ahmed
    Replies:
    1
    Views:
    5,214
    =?Utf-8?B?U2VyZ2V5IFBvYmVyZXpvdnNraXk=?=
    Oct 25, 2005
  4. Replies:
    8
    Views:
    706
    Kevin Spencer
    Dec 9, 2005
  5. John Dalberg

    Tool to move inline code to code behind?

    John Dalberg, Mar 20, 2007, in forum: ASP .Net
    Replies:
    1
    Views:
    324
    Alvin Bruney [MVP]
    Mar 22, 2007
Loading...

Share This Page