Ext.Net web.config全局属性配置

来源:互联网 发布:淘宝乔丹好店铺 编辑:程序博客网 时间:2024/06/06 11:45
 

WEB.CONFIG 配置例子


如何让EXT.NET支持视图变量ViewState


根据以上的说明,我们可以对 EXT.NET 进行很多配置。

比如,让 EXT.NET 支持视图变量。默认情况下,EXT.NET不保存页面变量,但是可以通过配置EXT.NET改变这点,毕竟有时使用ViewState还是挺方便的。


WEB.CONFIG配置


view plaincopy to clipboardprint?
  1. <configuration>  
view plaincopy to clipboardprint?
  1.  <configSections>  
  2.    <section name="extnet" type="Ext.Net.GlobalConfig" requirePermission="false" ></section>  
  3.  </configSections>  
  4.  <extnet ajaxViewStateMode="Enabled" />  
  5. </configuration>  
  6. <httpHandlers>  
  7.  <add path="*/ext.axd" verb="*" type="Ext.Net.ResourceHandler" validate="false" />  
  8. </httpHandlers>  

例子

view plaincopy to clipboardprint?
  1. <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Test.aspx.cs" Inherits="AM.Web.Pages.Test" %>  
  2.   
  3. <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>  
  4. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
  5. <html xmlns="http://www.w3.org/1999/xhtml">  
  6. <head runat="server">  
  7.     <title></title>  
  8. </head>  
  9. <body>  
  10.     <form id="form1" runat="server">  
  11.     <ext:ResourceManager ID="ResourceManager1" runat="server" />  
  12.     <ext:Button ID="Button1" runat="server" OnDirectClick="Button1_Click" Text="ViewState">  
  13.     </ext:Button>  
  14.     <ext:TextField ID="TextField1" runat="server" Text="">  
  15.     </ext:TextField>  
  16.     </form>  
  17. </body>  
  18. </html>  
view plaincopy to clipboardprint?
  1. using System;  
  2. using System.Collections.Generic;  
  3. using System.Linq;  
  4. using System.Web;  
  5. using System.Web.UI;  
  6. using System.Web.UI.WebControls;  
  7. using Ext.Net;  
  8.   
  9. namespace AM.Web.Pages  
  10. {  
  11.     public partial class Test : System.Web.UI.Page  
  12.     {  
  13.         public string myStr  
  14.         {  
  15.             get  
  16.             {  
  17.                 if (this.ViewState["myStr"] == null)  
  18.                 {  
  19.                     return string.Empty;  
  20.                 }  
  21.                 return this.ViewState["myStr"].ToString();  
  22.   
  23.             }  
  24.             set  
  25.             {  
  26.                 this.ViewState["myStr"] = value;  
  27.             }  
  28.         }  
  29.         protected void Page_Load(object sender, EventArgs e)  
  30.         {  
  31.             if (!X.IsAjaxRequest)  
  32.             {  
  33.                 myStr = "AAAAAAAAAAAAAAAAAAAAAA";  
  34.             }  
  35.         }  
  36.         protected void Button1_Click(object sender, DirectEventArgs e)  
  37.         {  
  38.             this.TextField1.Text = myStr;  
  39.         }  
  40.     }