Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6145045
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:44:21+00:00 2026-05-23T18:44:21+00:00

I like to Monkey patch a ASPX website so that I can add stuff

  • 0

I like to Monkey patch a ASPX website so that I can add stuff to the Page_Load method within a compiled assembly.

My first thought was to add a script tag containing a second Page_Load method to the ASPX file like so:

<script language="CS" runat="server">
void Page_Load(object sender, System.EventArgs e) 
{
     // do some stuff in addition to the original Page_Load method
}
</script>

But it looks like only the Page_Load method from the inline code will be executed and not the one from the original code-behind file (within the compiled assembly).

Is it possible to call the original method from within my inline code? Or is there any other way to add stuff that should run directly after the Page_Load method was called from within inline code without modifying the existing assembly?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T18:44:21+00:00Added an answer on May 23, 2026 at 6:44 pm

    The asp.net model is that the page declared in the .aspx file is actally a descendant class from the class that inherits from System.Web.UI.Page declared in the .aspx.cs file.

    So your Page_Load method is called because it basically hides the original Page_Load method. Following that logic, you could do:

    <script language="CS" runat="server"> 
    void Page_Load(object sender, System.EventArgs e)  
    {      
       base.Page_Load(sender, e);
       // do some stuff in addition to the original Page_Load method 
    } 
    </script> 
    

    There are no accessibility issues because asp.net by default declares Page_Load and similar methods as protected so descendant classes can call them.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The question How can I monkey-patch an instance method in Perl? got me thinking.
How can I extract the date from a string like monkey 2010-07-10 love banana?
I have a JSON array that looks like this: ['Monkey','Cheetah','Elephant','Lizard','Spider'] I also have a
Lets use a real world example. I want to monkey patch WillPaginate::LinkRenderer.to_html method. So
I have a list of lists that looks like this: animal_groups = [['fox','monkey', 'zebra'],
I'd really like to handle this without monkey-patching but I haven't been able to
Like the Delicious submission bookmark-let, I'd like to have some standard JavaScript I can
It looks like that the 'grid' option in the constructor of Draggable is relatively
A gem I am using inserts an after_save callback that I would like to
I've created a .net assembly that includes the data contract for a WCF (win32)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.