Note that there are some explanatory texts on larger screens.

plurals
  1. POASP.NET 4.0 C# "state information is invalid for this page and might be corrupted." MasterPage->Aspx->Ascx
    text
    copied!<p>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.</p> <p>I have a blank project with a single master page, a single page, and a single control.</p> <p>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.</p> <p>This is the aspx:</p> <pre><code> &lt;%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" EnableEventValidation="false" AutoEventWireup="true" CodeBehind="Outer.aspx.cs" Inherits="TestProject.Outer" %&gt; &lt;asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server"&gt; &lt;script type="text/javascript"&gt; 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); } &lt;/script&gt; &lt;/asp:Content&gt; &lt;asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server"&gt; &lt;asp:ScriptManager ID="ScriptMgr" runat="server" EnablePageMethods="true"&gt; &lt;/asp:ScriptManager&gt; &lt;div id="leftSideContent"&gt; &lt;input type='button' id="clickToLoadASCX" value="Click Me" onclick="loadUserView('/inner.ascx');"/&gt; This is the "Outer.aspx" page which will hold the ascx after the button is clicked &lt;/div&gt; &lt;div id="divRightMainContentView"&gt; &lt;/div&gt; &lt;/asp:Content&gt; </code></pre> <p>Aspx code behind (which renders the ascx)</p> <pre><code> [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(); } </code></pre> <p>This is the ascx called inner.ascx</p> <pre><code>&lt;%@ Control Language="C#" AutoEventWireup="true" CodeBehind="inner.ascx.cs" Inherits="TestProject.inner" %&gt; &lt;div&gt; This is the inner text. When I click the button below I should proceed to inner.ascx.cs to the "PageBehindCall_Submit". &lt;asp:Button ID="innerButton" runat="server" onclick="PageBehindCall_Submit" Text="Submit"/&gt; &lt;/div&gt; </code></pre> <p>And finally, the ascx code-behind</p> <pre><code>protected void PageBehindCall_Submit(object sender, EventArgs e) { string str = "This call does not work!"; } </code></pre> <p>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!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload