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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T22:11:58+00:00 2026-06-17T22:11:58+00:00

This is my first SO post, so please forgive any faux pas. I feel

  • 0

This is my first SO post, so please forgive any faux pas. I feel as though I’ve tried everything on every post related to this error (disable viewstate, noCache, etc) and I’m at my wits end.

I have a blank project with a single master page, a single page, and a single control.

The page (aspx) loads using the master page. This works fine. There is a button on the page which loads the control (the ascx) onto the aspx in the section called divRightMainView. This also works fine (which is where my problem seems to differ from all others I’ve found…). There is a button on the ascx which is supposed to call the code-behind of the ascx – this is where I get the “state information” error.

This is the aspx:

    <%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master"                   EnableEventValidation="false" AutoEventWireup="true" CodeBehind="Outer.aspx.cs"   Inherits="TestProject.Outer" %>
    <asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
    <script  type="text/javascript">
        function loadUserView(viewToLoad) {
            PageMethods.RenderControl(viewToLoad, onSuccess, onError);
        }

        function onSuccess(results) {
            alert(results);
            var command = results.split('##')[0];

            if (command == 'loadView') {
                var htmlToLoad = results.split('##')[1];
                $get('divRightMainContentView').innerHTML = htmlToLoad;
            }
        }

        function onError(error) {
            alert('error ' + error);
        }

    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <asp:ScriptManager ID="ScriptMgr" runat="server" EnablePageMethods="true">
    </asp:ScriptManager>
     <div id="leftSideContent">
         <input type='button' id="clickToLoadASCX" value="Click Me" onclick="loadUserView('/inner.ascx');"/>
         This is the "Outer.aspx" page which will hold the ascx after the button is clicked
     </div>
     <div id="divRightMainContentView">

     </div>
</asp:Content>

Aspx code behind (which renders the ascx)

 [WebMethod]
    public static string RenderControl(String controlName)
    {

        Page page = new Page();
        Control control = page.LoadControl(controlName);
        HtmlForm form = new HtmlForm();
        form.Controls.Add(control);
        page.Controls.Add(form);
        StringWriter writer = new StringWriter();
        HttpContext.Current.Server.Execute(page, writer, false);
        return "loadView##" + writer.ToString();
    }

This is the ascx called inner.ascx

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="inner.ascx.cs" Inherits="TestProject.inner" %>

<div>
    This is the inner text. When I click the button below I should proceed to inner.ascx.cs to the "PageBehindCall_Submit".
    <asp:Button ID="innerButton" runat="server" onclick="PageBehindCall_Submit" Text="Submit"/> 
</div>

And finally, the ascx code-behind

protected void PageBehindCall_Submit(object sender, EventArgs e)
{
    string str = "This call does not work!";
}

I’m hoping to be able to use the “PageBehindCall_Submit” to process data, grab inputs from the ascx, etc. Let me know if there is a way to make this happen, or another possible work-around? Any help would be appreciated!

  • 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-06-17T22:12:00+00:00Added an answer on June 17, 2026 at 10:12 pm

    Why not load the ascx on page load of the ascx but turn the visibility off rather than manually rendering user control html. This is very weird that it does not hook up with the event in ascx as the control belongs to ascx. But I think you should add it in aspx then try to turn on visibility whenever you need it.

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

Sidebar

Related Questions

This is my first post here so please forgive any protocol errors. My question
This is my first post, and first please forgive me for my poor english.
This is my first post, so please forgive me if this question has been
This is my first post so if any other information is needed please let
This is my first post. Please forgive me for asking a basic question as
This is my first post in this type of forum so please forgive my
Okay this is my first post here so please forgive me if i mess
This is my first post in any forum so please bear with me. I
This is my first post on Stack Overflow so please exuse (and feel free
[please forgive formatting errors-- first post here and I tried earnestly to do it

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.