The official release of Ext.NET Mobile is now available. Ext.NET Mobile is an ASP.NET component framework for building Phone and Tablet specific mobile web applications. Read More

[CLOSED] Using ContentPlaceHolder will Makes "The state information is invalid for this page and might be corrupted" Exception

Page 2 of 2 FirstFirst 12
  1. #11
    Fabricio,

    But one more question, why my button no response after I mark out the AntiXsrfTokenKey viewstate related code?

    The view code is

    <%@ Page Title="About" Language="C#" MasterPageFile="Site.Master" AutoEventWireup="true" CodeBehind="About.aspx.cs" Inherits="TestWebForm.About" %>
    
    <asp:Content ID="BodyContent" ContentPlaceHolderID="MainContent" runat="server">
        <ext:Panel runat="server">
            <Items>
                <ext:FormPanel runat="server">
            <Items>
                <ext:Panel runat="server">
                    <Items>
                        <ext:GridPanel ID="gridOrg" runat="server" Title="医疗机构" ColumnLines="true" Height="200">
                            <TopBar>
                                <ext:Toolbar ID="GridOrgToolbar" runat="server">
                                    <Items>
                                        <ext:Button ID="BtnAdd" Text="新增" runat="server">
                                            <DirectEvents>
                                                <Click OnEvent="OnOrgCreate" />                                  
                                            </DirectEvents>
                                        </ext:Button>
                                    </Items>
                                </ext:Toolbar>
                            </TopBar>
                        </ext:GridPanel>
                    </Items>
                </ext:Panel>
                
            </Items>
        </ext:FormPanel>
            </Items>
        </ext:Panel>
        
    </asp:Content>
    code behind is:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using Ext.Net;
    
    namespace TestWebForm {
        public partial class About : Page {
            protected void Page_Load(object sender, EventArgs e) {
    
            }
    
            protected void OnOrgCreate(object sender, DirectEventArgs e) {
                X.Msg.Alert("System Msg", "hello");
            }
        }
    }
    It just return "{}" in resopnse. No Message Dialog


    BTW,
    Your advice is to mark out the viewstate code, right? But this is the code visual studio template generate for us. I think everyone will encounter this problem in new project. Maybe it should be log as bug will be better.
    Last edited by u8621011; Apr 26, 2017 at 1:08 AM.
  2. #12
    Hello Ted!

    Your inquiry about why you receive an empty ({}) response with your code is exactly what I tried to tell you in my post here! :)

    If you just X.Msg.Alert('title', 'message') Ext.NET will have but naught to be emitted to JavaScript. You have instantiated a message box but didn't give it an order. Either to add -- as a component -- to the page, or to show as a hidden window or -- yes! -- a MessageBox or kind of alert/modal window.

    So, again, this is not going to ever give you any return. You must (sorry, no better word) change it from:

    protected void OnOrgCreate(object sender, DirectEventArgs e) {
        X.Msg.Alert("System Msg", "hello");
    }
    to:

    protected void OnOrgCreate(object sender, DirectEventArgs e) {
        X.Msg.Alert("System Msg", "hello").Show();
    }
    So that the dialog is displayed after the server command returns (triggering a callback that will run the resulting JavaScript code).

    I hope this now clarifies this detail.

    Now, on your second inquiry:

    This is not really a bug, just that the WebForms template from Visual Studio comes with code that is not compatible with Ext.NET to be used as a master page.

    There is another incompatible concept that is the FriendlyURLs. It removes the extension from .aspx files and requires further changes in either Ext.NET or the template's code before a page can work. If you create a WebForms project with an empty template, and create your Master page, it will work fine. Check the picture below, I believe it illustrates well what I'm talking about.

    Click image for larger version. 

Name:	61870-newWFProject.png 
Views:	1 
Size:	34.7 KB 
ID:	24923

    This does not mean Ext.NET is not compatible or broken to the template. Just that it disables a functionality required for Ext.NET to work. The programming instructions used in the Master page are not interoperable with Ext.NET and should be adapted to work with Ext.NET. As much as you need to add the ResourceManager to the master page in order for the Ext.NET slave pages (from that master) to work without each defining their own resource manager.

    For the specific case of the code on Master Page that should be removed before Ext.NET works, actually Ext.NET would require additional settings/parameters in order to work with the AntiXSRF. There is a discussion on using AntiXSRF with Ext.NET, and that would be the review necessary in order to use Ext.NET with that Master Page.

    I hope this helps clarify the matter. If not, let us know.
    Fabrício Murta
    Developer & Support Expert
  3. #13
    Fabricio,

    sorry, i didn't see the show command. You also mentioned another possbile problem of FriendlyURLs, what i have to modified?

    I also see the FeindlyUrlSettings in my generated router registration.

    Ted
  4. #14
    Hello Ted,

    It was under App_Start/RouteConfig.cs. I have a project here that reads like this (I just commented them out):

    public static void RegisterRoutes(RouteCollection routes)
    {
        //var settings = new FriendlyUrlSettings();
        //settings.AutoRedirectMode = RedirectMode.Permanent;
        //routes.EnableFriendlyUrls(settings);
      
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
        routes.IgnoreRoute("{exclude}/{extnet}/ext.axd");
    
        routes.MapRoute(
                name: "Default",
                url: "{controller}/{action}/{id}",
                defaults: new { action = "Index", id = UrlParameter.Optional }
            );
    }
    Notice said project has both WebForms and MVC bindings, your project may or may not have this file or this code depending on the version of Visual Studio and template you used while creating the examples.

    Also, you may actually be able to use the feature, as it just fiddles with URLs removing the .aspx extension from pages and this might break some examples where you reference the pages using the extension. So maybe if your project works thus far you don't really need to change this.

    Hope this helps!
    Fabrício Murta
    Developer & Support Expert
  5. #15
    Fabricio,

    OK, I got it and thanks for your clear explanation.

    Ted
  6. #16
    Glad it was helpful, we're here to help however we can!
    Fabrício Murta
    Developer & Support Expert
Page 2 of 2 FirstFirst 12

Similar Threads

  1. Replies: 0
    Last Post: Jan 24, 2014, 4:57 PM
  2. Replies: 7
    Last Post: Dec 19, 2013, 7:16 PM
  3. <%@ Page Language="C#" Buffer="false" %>
    By zanotto in forum 2.x Help
    Replies: 2
    Last Post: Nov 21, 2013, 4:32 PM
  4. Replies: 2
    Last Post: Jun 26, 2011, 1:59 AM
  5. Replies: 1
    Last Post: Mar 13, 2011, 9:21 AM

Posting Permissions

Subscribe now to get the latest Ext.NET happenings in our newsletter.