⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 customize.aspx

📁 ASP_NET程序设计教程 源代码 冶金工业出版社 肖金秀 冯沃辉 陈少涌
💻 ASPX
字号:
<html>
 

  <script language="VB" runat="server">

      Sub Page_Load(Sender As Object, E As EventArgs)

        If Not (IsPostBack)
          Dim Cookie As HttpCookie = Request.Cookies("preferences1")
          ViewState("引用站点") = Request.Headers("引用站点")

          If Not Cookie Is Nothing
            BackColor.Value = CStr(Cookie.Values("BackColor"))
            ForeColor.Value = CStr(cookie.Values("ForeColor"))
            LinkColor.Value = CStr(cookie.Values("LinkColor"))
            FontSize.Value = CStr(cookie.Values("FontSize"))
            FontName.Value = CStr(cookie.Values("FontName"))
          End If
        End If
      End Sub

      Sub Submit_Click(Sender As Object, E As EventArgs)

        Dim Cookie As HttpCookie
        Cookie = New HttpCookie("preferences1")

        Cookie.Values.Add("ForeColor",ForeColor.Value)
        Cookie.Values.Add("BackColor",BackColor.Value)
        Cookie.Values.Add("LinkColor",LinkColor.Value)
        Cookie.Values.Add("FontSize",FontSize.Value)
        Cookie.Values.Add("FontName",FontName.Value)
        Response.AppendCookie(Cookie)

        If Not ViewState("引用站点") Is Nothing Then
          Response.Redirect(ViewState("引用站点").ToString())
        End If
      End Sub

      Sub Cancel_Click(Sender As Object, E As EventArgs)
        If Not ViewState("引用站点") Is Nothing Then
          Response.Redirect(ViewState("引用站点").ToString())
        End If
      End Sub

      Function GetStyle(Key As String) As String

        Dim Cookie As HttpCookie
        Cookie = Request.Cookies("preferences1")

        If Not Cookie Is Nothing

          Select (Key)

            Case "ForeColor" :
              Return Cookie.Values("ForeColor")

            Case "BackColor" :
              Return Cookie.Values("BackColor")

            Case "LinkColor" :
              Return Cookie.Values("LinkColor")

            Case "FontSize" :
              Return Cookie.Values("FontSize")

            Case "FontName" :
              Return Cookie.Values("FontName")
          End Select
        End If

        Return ""
      End Function

  </script>

  <style>

    body {
      font: <%=GetStyle("FontSize")%> <%=GetStyle("FontName")%>;
      background-color: <%=GetStyle("BackColor")%>;
    }

    table {
      font: <%=GetStyle("FontSize")%> <%=GetStyle("FontName")%>;
      background-color: <%=GetStyle("BackColor")%>;
      foreground-color: <%=GetStyle("ForeColor")%>
    }

    a { color: <%=GetStyle("LinkColor")%> }

  </style>

  <body style="color:<%=GetStyle("ForeColor")%>">

    <form runat="server">

    <h3><font face="宋体">自定义此页</font></h3>

    <b>选择您的首选项:</b><p>

    <table style="color:<%=GetStyle("ForeColor")%>">
      <tr>
        <td>背景色:</td>
        <td>
          <select id="BackColor" runat="server">
            <option>beige</option>
            <option>yellow</option>
            <option>red</option>
            <option>blue</option>
            <option>lightblue</option>
            <option>lightgreen</option>
            <option>black</option>
            <option>white</option>
          </select>
        </td>
      </tr>
      <tr>
        <td>前景色:</td>
        <td>
          <select id="ForeColor" runat="server">
            <option>black</option>
            <option>beige</option>
            <option>yellow</option>
            <option>red</option>
            <option>blue</option>
            <option>lightblue</option>
            <option>lightgreen</option>
            <option>white</option>
          </select>
        </td>
      </tr>
      <tr>
        <td>超级链接的颜色:</td>
        <td>
          <select id="LinkColor" runat="server">
            <option>blue</option>
            <option>beige</option>
            <option>yellow</option>
            <option>red</option>
            <option>lightblue</option>
            <option>lightgreen</option>
            <option>black</option>
            <option>white</option>
          </select>
        </td>
      </tr>
      <tr>
        <td>字体大小:</td>
        <td>
          <select id="FontSize" runat="server">
            <option>9pt</option>
            <option>10.5pt</option>
            <option>12pt</option>
            <option>14pt</option>
          </select>
        </td>
      </tr>
      <tr>
        <td>字体名称:</td>
        <td>
          <select id="FontName" runat="server">
            <option>宋体</option>
            <option>Tahoma</option>
            <option>Arial</option>
            <option>Times</option>
          </select>
        </td>
      </tr>
    </table>

    <p>

    <input type="submit" OnServerClick="Cancel_Click" Value="取消" runat="server"/>
    <input type="submit" OnServerClick="Submit_Click" Value="提交" runat="server"/>

    </form>

  </body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -