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

  • Home
  • SEARCH
  • 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 965647
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T02:02:00+00:00 2026-05-16T02:02:00+00:00

while the method we use in Substitution control should return strings, so how is

  • 0

while the method we use in Substitution control should return strings, so how is it possible to use a donut caching in web forms on a server control which should be rendered server side?
for example Loginview control?

  • 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-16T02:02:00+00:00Added an answer on May 16, 2026 at 2:02 am

    UPDATE
    This is now a fully working example. There a few things happening here:

    1. Use the call back of a substitution control to render the output of the usercontrol you need.
    2. Use a custom page class that overrides the VerifyRenderingInServerForm and EnableEventValidation to load the control in order to prevent errors from being thrown when the usercontrol contains server controls that require a form tag or event validation.

    Here’s the markup:

    <asp:Substitution runat="server" methodname="GetCustomersByCountry" />
    

    Here’s the callback

    public string GetCustomersByCountry(string country)
    {
       CustomerCollection customers = DataContext.GetCustomersByCountry(country);
    
        if (customers.Count > 0)
            //RenderView returns the rendered HTML in the context of the callback
            return ViewManager.RenderView("customers.ascx", customers);
        else
            return ViewManager.RenderView("nocustomersfound.ascx");
    }
    

    Here’s the helper class to render the user control

    public class ViewManager
    {
        private class PageForRenderingUserControl : Page
        {
            public override void VerifyRenderingInServerForm(Control control)
            { /* Do nothing */ }
    
            public override bool EnableEventValidation
            {
                get { return false; }
                set { /* Do nothing */}
            }
        }
    
        public static string RenderView(string path, object data)
        {
            PageForRenderingUserControl pageHolder = new PageForUserControlRendering();
            UserControl viewControl = (UserControl) pageHolder.LoadControl(path);
    
            if (data != null)
            {
                Type viewControlType = viewControl.GetType();
                FieldInfo field = viewControlType.GetField("Data");
                if (field != null)
                {
                    field.SetValue(viewControl, data);
                }
                else
                {
                    throw new Exception("ViewFile: " + path + "has no data property");
                }
            }
    
            pageHolder.Controls.Add(viewControl);
            StringWriter result = new StringWriter();
            HttpContext.Current.Server.Execute(pageHolder, result, false);
            return result.ToString();
        }
    }
    

    See these related questions:

    • Turn off page-level caching in a
      user control
    • UserControl’s RenderControl is
      asking for a form tag in (C#
      .NET)
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I Want to know which one is preferred while coding to use Static Methods
If you define a While method of the builder-object, you can use while -loops
What I what to accomplish is to use (rely on) current_user method while defining
we can use both the method while passing parameters to sql query ? then
i wan to call mvc controller method while page load : public ActionResult Detail(int
As of now I'm using a while(true) method to detect changes in memory. The
Iam getting OutOfMemoryException while making remote method call. RemoteEntity.SetLocalStore(DATASET); passed value is dataset. Note
I'm getting an Illegal characters in path error while using XMLTextReader method. Basically, I'm
We always alloc before init in Objective C, then while writing init method, Why
While writing an encryption method in JavaScript, I came to wondering what character encoding

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.