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 6063149
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:07:59+00:00 2026-05-23T09:07:59+00:00

I have a weird scenario but this was how it was designed before me.

  • 0

I have a weird scenario but this was how it was designed before me. Basically I have userControl, and there is a child.masterpage

in the userControl in the ascx file it contains the following

<div><%=_template%></div>

the child.masterpage inherits from a parent.masterpage, in the child.masterpage there is a call to the userControl

<asp:Content><ucc:UserControl></ucc>

the parent.masterpage has other fields in it and it has a .cs file with a c# function

public void passVal(string s)

Now what I want to do is to pass a value from the user control directly to the parent.masterpage function so that I can put it in the parent.masterpage literal I have created.

How can I achieve this (again, this is existing design and I cant turn things around) I am just adding a functionality.

<%@ Master Language="C#" AutoEventWireup="true" MasterPageFile="../common/main.master" %>
<%@ Register Src="UserControl.ascx" TagName="Ord" TagPrefix="uc" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" Runat="Server">
<div class="in"><uc:OrderReceipt ID="myord" runat="server" Visible="true"/>
 <div style="margin-bottom:30px;">
<a href="~/" id="HomeLink" runat="server" class="BackLink">Back to Home Page</a>
</div>
</asp:Content>
  • 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-23T09:07:59+00:00Added an answer on May 23, 2026 at 9:07 am

    You can use the Page.Master property to get a hold of the master page instance.

    protected someEvent(object sender, EventArgs e)
    {
       (Page.Master as ChildMaster).passVal("some string");
    }
    

    More of an Answer:

    I was just reviewing your OP and realized something. The code that kept puzzling me was the user control.

    in the userControl in the ascx file it
    contains the following

    <div><%=_template%></div>

    I haven’t seen the code behind but my guess is that the user control is simply used to output dynamic HTML. I bet if you looked at the code behind (.cs file) of the user control, you would find a variable called _template. It is a string variable that is pumped with html at run time.

    Now, that doesn’t answer your question but, if you didn’t already know that … it is good to know =P

    Now, the next mystery is the one concerning your missing code behind file for the child master page.

    My theory is that whoever made it did it with some error that would cause it not to automatically generate a code behind file. Or, they made it from scratch and just simply added it to the project but neglected to make a code behind as well.

    I made a master page, then made another one called child. I am able to subclass it and here is what the markup and code behind look like.

    <%@ Master Language="C#" MasterPageFile="~/Master.master" AutoEventWireup="true"   CodeFile="Child.master.cs" Inherits="Child" %>
    
    <asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
    </asp:Content>
    <asp:Content ID="Content2" ContentPlaceHolderID="body" Runat="Server">
    </asp:Content>
    
    public partial class Child : Master
    {
        protected void Page_Load(object sender, EventArgs e)
        {
    
        }
    }
    

    In comparing the markup to yours, the key difference here is that mine explicitly mentions a CodeFile attribute.

    Create a new cs file and following the naming convention. Then add the CodeFile and Inherits attributes to your child master page. This should wire everything up correctly and allow you to start adding methods and such to the child master page.

    Let me know where you are at and we’ll take it from there. GL

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

Sidebar

Related Questions

This is a little weird. I have the following scenario: A page containing a
I have a very weird bug here, this is the scenario; -I click on
I have this weird problem with setting up cookies with PHP. Everything worked fine
Have a weird scenario where the ADO.Net keep returning SQLite error. Insufficient parameters supplied
I have a very weird scenario in struts2. When I do the following: <s:property
Now this is a weird one We have a project where we are reading
I have got an Excel file in this form : Column 1 Column 2
This is a weird requirement I have. I know even my question is quite
I have a weird scenario in which the website seems to randomly run out
This is a bit of weird scenario. I had a class that was quickly

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.