asp.net动态切换主题
2014-03-29 22:41 -夜 阅读(187) 评论(0) 编辑 收藏 举报C#代码
protected void Page_PreInit(object sender, EventArgs e) { if (Request.QueryString["theme"] != null) { switch (Request.QueryString["theme"]) { case "Blue": Page.Theme = "BlueTheme"; break; case "Pink": Page.Theme = "PinkTheme"; break; } } }JavaScript代码
<script type="text/javascript"> function changeTheme() { var theme = document.getElementById("ddlTheme").value; var url = window.location.href.replace(/(^\s*)|(\s*$)/g, "");//获取去处两边空格之后当前url if (url.indexOf("?") == -1) { //查找?的索引位置 url += "?theme=" + theme; } else if (url.indexOf("?") == url.length - 1) { url += "theme=" + theme; } else { url += "&theme=" + theme; } window.location = url;//重新加载当前页 } </script>
版权声明:本文为博主原创文章,未经博主允许不得转载。