上方廣告

2009年10月13日 星期二

在.cs檔裡動態註冊JavaScript和CSS

//註冊CSS
string stylestr = "<style type='text/css'>";
stylestr += ".smallstyle";
stylestr += "{";
stylestr += "font-size: 12px;";
stylestr += "font-family: '新細明體';";
stylestr += "color: Gray;";
stylestr += "}";
stylestr += ".bigbodystyle";
stylestr += "{";
stylestr += "font-size: 20px;";
stylestr += "font-family: '新細明體';";
stylestr += "}";
stylestr += "</style>";

Page.RegisterClientScriptBlock("HideBlock", stylestr);