zoukankan      html  css  js  c++  java
  • Coolite调用母版页里的方法

     在UserControl(ascx),MasterPage或者Page(aspx)中使用Coolite的AjaxMetod讲究是不同的,在MasterPage中或者你在类似DotNetNuke的系统中调用AjaxMetod标志的方法,默认情况下是会找不到方法的,

    处理此类问题需要使用AjaxMethodProxyID,使用的方法是在类的前面加上,如下
    [AjaxMethodProxyID(IDMode = AjaxMethodProxyIDMode.None)]
    partial class ModuleRightManager : PortalModuleBase

    在有MasterPage页面或者在类似DotNetNuke的CMS系统下使用Coolite的AJAXMethod,建议你在页面的前部加上:

    [AjaxMethodProxyID(IDMode = AjaxMethodProxyIDMode.ClientID)]
    public partial class PopupCustomerDetail : PortalModuleBase

     例子:
    母版页.cs:

    代码
    using System;    
    using System.Collections.Generic;    
    using System.Linq;    
    using System.Web;    
    using System.Web.UI;    
    using System.Web.UI.WebControls;    
    using Coolite.Ext.Web;    
       
    [AjaxMethodProxyID(IDMode 
    = AjaxMethodProxyIDMode.None)]    
    public partial class Base : System.Web.UI.MasterPage    
    {    
        
    protected void Page_Load(object sender, EventArgs e)    
        {    
       
        }    
       
        [AjaxMethod]    
        
    public string PageMethod()    
        {    
            
    return "调用了模板页的方法PageMethod();";    
        }    
       
    }   

    内容页:

    代码
    <%@ Page Title="" Language="C#" MasterPageFile="~/Base.master" AutoEventWireup="true" CodeFile="test.aspx.cs" Inherits="test" %>    
       
    <%@ Register assembly="Coolite.Ext.Web" namespace="Coolite.Ext.Web" tagprefix="ext" %>    
       
    <asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">    
    </asp:Content>    
    <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">    
        
    <ext:ScriptManager ID="ScriptManager1" runat="server" />    
        
    <ext:Button ID="Button1" runat="server" Text="点我">    
            
    <Listeners>        
            
    <Click Handler="      
                 Coolite.AjaxMethods.PageMethod({      
                     success: function(result) {      
                         Ext.Msg.alert(
    '提示信息', result);      
                     }      
                 });
    " />        
            </Listeners>        
        
    </ext:Button>    
       
    </asp:Content>   

    以下是几种AjaxMethodProxyID 的区别:

    1. None - 命名前缀是空的,调用方法时直接使用 Coolite.AjaxMethods.ajaxMethod(...)
    2. ClientID - 命名前缀需要加上当前类控件的client id(客户端前缀) ,如Coolite.AjaxMethods.ctl00_UC1.ajaxMethod ,当然通常情况下我们Coolite.AjaxMethods.<%=this.ClientID>.ajaxMethod(...)
    3. ID - 使用当前控件ID作为前缀, Coolite.AjaxMethods.UC1.ajaxMethod(...)
    4. Alias - 使用别名做前缀,你可以声明自己的一个别名, Coolite.AjaxMethods.myAlias.ajaxMethod(...)
    5. AliasPlusID - 别名和ID同时使用,如 Coolite.AjaxMethods.myAliasUC1.ajaxMethod(...) 

     
  • 相关阅读:
    机器学习入门实践——线性回归&非线性回归&mnist手写体识别
    基于OpenCV的摄像头采集印刷体数字识别
    使用rviz实现本地计算机绘制机器人路径
    从0开始的FreeRTOS(4)
    从0开始的FreeRTOS(3)
    从0开始的FreeRTOS(2)
    从0开始的FreeRTOS(1)
    Robomaster电控入门(8)RTOS
    Robomaster电控入门(7)双轴云台控制
    计算机与网络课程设计开发纪要
  • 原文地址:https://www.cnblogs.com/KingStar/p/1771391.html
Copyright © 2011-2022 走看看