我想 大家對MagicAjax都很了解了吧,我再把MagicAJax的使用說一遍:
1.到 http://www.magicAJax.Net/ 下載最新的DLL組件以及源碼包;
2.配置 Web.config:
<configSections>
<section name="magicAjax" type="MagicAjax.Configuration.MagicAjaxSectionHandler, MagicAJax" />
</configSections>
<magicAJax scriptPath="~/Script" outputCompareMode="HashCode" tracing="false">
<pageStore mode="NoStore" unloadStoredPage="false" cacheTimeout="5" maxConcurrentPages="5" maxPagesLimitAlert="false"/>
</magicAJax>
<pages>
<controls>
<add tagPrefix="ajax" namespace="MagicAjax.UI.Controls" assembly="MagicAJax"/>
</controls>
</pages>
<httpModules>
<add name="MagicAjaxModule" type="MagicAjax.MagicAjaxModule, MagicAJax" />
</httpModules>
3.在你需要用到MagicAJax的頁面頭部聲明:
<%@ Register TagPrefix="ajax" Namespace="MagicAjax.UI.Controls" Assembly="MagicAJax" %>
用AJaxPanle包含你要進行無刷新的控件;
<ASP:Content runat="server" ID="LinkButton_Content" ContentPlaceHolderID="LinkButton_ContentPlaceHolder">
<ajax:AjaxPanel runat="server" ID="AJaxPanle0">
<uc7:MasterTemplate runat="server" ID="MasterTemplate1" />
</ajax:AJaxPanel>
</ASP:Content>
<ASP:Content runat="server" ID="Menu_Content" ContentPlaceHolderID="menu_ContentPlaceHolder">
<ajax:AjaxPanel runat="server" ID="AJaxPanel1">
<ASP:WebPartZone ID="WebPartZone1" runat="server" SkinID="WebPartZoneSkin">
<ZoneTemplate>
<uc4:Menu ID="Menu1" runat="server" SiteId="-1" ModuleCode="1000" Rows="1" Columns="10"
PanelWidth="100%" HrefCSS="link2" SiteConfig="SiteCode" />
</ZoneTemplate>
</ASP:WebPartZone>
</ajax:AJaxPanel>
</ASP:Content>
到此,所有的工作已經完成,你就可以完成無刷新了。。。簡單吧。。。哈哈。。。
注:
關於 Loading... 字體,有些人想改變成中文,這個當然可以實現,但是在Web.config裡面進行設置,會出現很多問題,譬如你頁面的編碼都亂了。那如何解決呢?
不要急,我們可以改變思維,用圖片來替代,如何?這個當然是可以實現的:
找到源碼包裡面的Script文件夾的AJaxCallObject.JS文件,找到
function CreateWaitElement() ...{
var elem = document.getElementById(''__AJaxCall_Wait'');
if (!elem) ...{
elem = document.createElement("div");
elem.id = ''__AJaxCall_Wait'';
elem.style.position = ''absolute'';
elem.style.height = 17;
elem.style.paddingLeft = "3px";
elem.style.paddingRight = "3px";
elem.style.fontSize = "11px";
elem.style.fontFamily = ''Arial, Verdana, Tahoma'';
elem.style.border = "#000000 1px solid";
elem.style.backgroundColor = "DimGray";
elem.style.color = "#ffffff";
elem.innerHtml = ''<img src="../Images/load.gif">'';
elem.style.visibility = ''hidden'';
document.body.insertBefore(elem, document.body.firstChild);
}
waitElement = elem;
}
把 elem.innerHtml = ''<img src="../Images/load.gif">''; 改成做好的圖片字樣就OK啦。。。