Using inline-code with code behind.

A

Anders M

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
 
K

Karl Seguin

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
 
A

Anders M

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
 
K

Karl Seguin

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!)
 
A

Anders M

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
 
A

Anders M

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

Anyone knows why?
/Anders
 
K

Karl Seguin

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!)
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top