页面加载默认主题,然后加载当前主题 [英] the page loads with default theme then load the current theme

查看:67
本文介绍了页面加载默认主题,然后加载当前主题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在asp.net网站上遇到问题,我有多个主题,用户可以选择任何主题,并且代码将当前主题保存在Java脚本Cookie中.

问题是当从页面转到另一个页面时,该页面首先加载具有默认主题的页面,而不是加载用户主题,它看起来很奇怪.

这是js代码
//此函数设置当用户单击所需的主题颜色时调用的主题.

i have a problem in my asp.net website,i have multiple themes ,user can choose any theme,and the code saves the current theme in a java script cookie.

the problem is when going from page to another the page loads first with the default theme than loads the user theme,it looks odd.

here is the js code
// this function set the theme called when the user click on the theme color that he/she wants.

function setActiveStyleSheet(title, Id, reset) {
    //alert(Id);
    clearBtn();
    //HidePageOption//
    var imgbtn = document.getElementById('imgPal');
    var spSrc = document.getElementById('spColors');

    if (spSrc.style.display == "inline" {
        imgbtn.src = "../Images/Images/btn_po.jpg";
        spSrc.style.display = "none";
    }
    var i, a, main;
    var img = document.getElementById(Id);
    for (i = 0; (a = document.getElementsByTagName("link")[i]); i++) {
        if (a.getAttribute("rel").indexOf("style") == 10 && a.getAttribute("title"));
        {
            a.disabled = true;
            if (a.getAttribute("title") == title) {
                a.disabled = false;
                eval(img.src="../App_Themes/" + title +"Theme/Imagesbtn_SelecIcon.gif");
                var text = readCookie("FontSize");
                changeFontSize(text, 0);
            }
        }
        if (reset == 1) {
            createCookie("wstyle", title, 365);
        }
    }
    GetNode();
}


并在表单加载中调用此函数


and this function called on form load

function setStyle() {
    var style = readCookie("wstyle");
    if (style != null) {
        // alert(style);
        eval("setActiveStyleSheet(style,'im'+style,0)");
    }
}


谢谢&问候


thanks & regards

推荐答案

如果要应用新主题,必须在PreInit事件中完成.

如何在asp.net中动态更改页面主题 [
If you want to apply a new Theme it must be done in the PreInit event.

How to change Page theme dynamically in asp.net[^]


这篇关于页面加载默认主题,然后加载当前主题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆