日韩久久久精品,亚洲精品久久久久久久久久久,亚洲欧美一区二区三区国产精品 ,一区二区福利

使用Ajax實現換膚功能

系統 1954 0
網站換膚是經常要用到的一個功能,但是傳統的方式似乎有點瑕疵,本文實現的Ajax換膚有點類似MSNSpace中的用戶體驗。

 功能:點擊linkbutton,在網頁中央彈出一個radio單選框,同時背景變成灰色,選擇這個單選框的選項,實現換膚功能。

這主要是ModalPopupExtender控件提供的功能,控件設置如下:

< ajaxToolkit:ModalPopupExtender ID ="ModalPopupExtender1" runat ="server" TargetControlID ="LinkButton1" PopupControlID ="Panel1" BackgroundCssClass ="modalBackground" DropShadow ="true" OkControlID ="OkButton" CancelControlID ="CancelButton" OnOkScript ="onOk()" >
</ ajaxToolkit:ModalPopupExtender >

TargetControlID:關聯觸發按鈕; PopupControlID:彈出的單選框,一般使用panel; BackgroundCssClass:彈出單選框后的背景色; DropShadow:彈出單選框后是否需要陰影; OkControlID:關聯確定按鈕; CancelControlID;關聯取消按鈕; OnOkScript:關聯選擇后應該執行的腳本。

其中onOk(),是響應Javascript的代碼,使用一個變量來替代css樣式。

以下是整個前臺代碼:

<% ... @PageLanguage = " C# " AutoEventWireup = " true " CodeFile = " changeCSS.aspx.cs " Inherits = " changeCSS " %>

<! DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >

< html xmlns ="http://www.w3.org/1999/xhtml" >
< head runat ="server" >
< title > 無標題頁 </ title >
< link href ="StyleSheet.css" rel ="stylesheet" type ="text/css" />
< script type ="text/javascript" > ...
var styleToSelect;
function onOk()
... {
document.getElementById(
' Paragraph1 ' ).className = styleToSelect;
}

</ script >
</ head >
< body >
< form id ="form1" runat ="server" >
< div >
< asp:ScriptManager ID ="ScriptManager1" runat ="server" >
</ asp:ScriptManager >

</ div >
< asp:LinkButton ID ="LinkButton1" runat ="server" Width ="240px" > Pleasechangethestyle </ asp:LinkButton >
< p id =Paragraph1 >
< a href ="http://blog.csdn.net/burningcpu" >< span style ="color:#3366cc" > burningcpu </ span ></ a > ,
IamZhouLu,amemeberofShangHaiIscom.netteam,lovesoftwaredevelopment,enjoyit.
</ p >
< asp:Panel ID ="Panel1" runat ="server" CssClass ="modalPopup" Style ="display:none" Width ="233px" >
< p > Choosethestyleyouwouldlike </ p >
< input id ="RadioA" name ="Radio" onclick ="styleToSelect='sampleStyleA';" type ="radio" />
< label class ="sampleStyleA" for ="RadioA" >
ChooseTHISStyle.
</ label >< br />
< input id ="RadioB" name ="Radio" onclick ="styleToSelect='sampleStyleB';" type ="radio" />
< label class ="sampleStyleB" for ="RadioB" >
ChooseTHISStyle.
</ label >< br />
< input id ="RadioC" name ="Radio" onclick ="styleToSelect='sampleStyleC';" type ="radio" />
< label class ="sampleStyleC" for ="RadioC" >
ChooseTHISStyle.
</ label >< br />
< input id ="RadioD" name ="Radio" onclick ="styleToSelect='sampleStyleD';" type ="radio" />
< label class ="sampleStyleD" for ="RadioD" >
ChooseTHISStyle.
</ label >< br />
< div align ="center" >
< asp:Button ID ="OkButton" runat ="server" Text ="OK" />
< asp:Button ID ="CancelButton" runat ="server" Text ="Cancel" />
</ div >
</ asp:Panel >
&nbsp;
< ajaxToolkit:ModalPopupExtender ID ="ModalPopupExtender1" runat ="server" TargetControlID ="LinkButton1" PopupControlID ="Panel1" BackgroundCssClass ="modalBackground" DropShadow ="true" OkControlID ="OkButton" CancelControlID ="CancelButton" OnOkScript ="onOk()" >
</ ajaxToolkit:ModalPopupExtender >
</ form >
</ body >
</ html >

實現效果:



使用Ajax實現換膚功能


更多文章、技術交流、商務合作、聯系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦!!!

發表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 大足县| 上栗县| 盐城市| 诏安县| 蒲城县| 苏州市| 英吉沙县| 兴国县| 曲水县| 鹿泉市| 聂荣县| 山阴县| 崇仁县| 北川| 汝城县| 澳门| 江安县| 安达市| 大渡口区| 应用必备| 抚松县| 盐山县| 峨眉山市| 什邡市| 万山特区| 徐水县| 镇安县| 连城县| 台江县| 西畴县| 四子王旗| 洱源县| 武胜县| 调兵山市| 汨罗市| 沽源县| 浦县| 通化县| 潼南县| 陵水| 巨鹿县|