页面加入_JS,CSS使用,#include添加文件,缓存页面,页面间传递汉字,IsPostBack控制页面的加载,自定义错语页面

1  页面加入_JS,
2  CSS使用,
3  #include添加文件,
4   缓存页面,
5   页面间传递汉字,
6    IsPostBack控制页面的加载,
7    自定义错语页面
=================
1  页面加入_JS,
    A:直接在页面里字JAVASCRIPT,调用:
       <script language="javascript">
          function  setfocus()
           {
              document.all.UserName.focus();
           }
        </script>
      <body onload="setfocus()">

     B:在页面里引用JS文件:
       <script type="text/javescript" src="heade.js"></script>
      <body onload="setfocus()">

2  CSS使用,
     style.css:
      body
       {
       }
       .inputstype
       {
        font:12pt 宋体;
        color:ret;
        }

     <link rel="stylesheet" type="text/css" href="style.css">
    <ASP:TextBox id="txtUser" CssClass="inputstyle" runat="server" />

3  #include添加文件,
    <body>
       <!--#Include File="a.asp"-->
   </body>

4   缓存页面,
    .ascx;.aspx缓存在页面HTML前面加入:
    <%@ OutPutCache duration="20" VaryByParam="none"%>

5   页面间传递汉字,
       页面间传递参数时有汉字和其它特殊字符($#@!%^&*)时,可以进行URL编码,解码;
     编码:  string str2 = System.web.HttpContext.Current.Server.UrlEncode(str1);
     解码:  string str=System.web.HttpContent.Current.server.urlDecode(str2);

6    IsPostBack控制页面的加载,
       IsPostBack是PAGE页面的一个属性,返回一个BOOL,true,false,据此值指示是否响应 客户端回发而重新加载;
       private void Page_Load(Object sender,System.EventArgs e)
       {
          if(!IspostBack=True)
               {
                 lab1.Text="页面每一次加载!";
               }
            else
                {
                lab1.Text="页面第二次,或3次以上加载";
                }
          }

7    自定义错语页面
 
       webconfig.xml
       <system.web>
          <customErrors defaultRedirect="err1.aspx"
           mode="On">   //出错时始终显示自己定义信息
       </system.web>
原文地址:https://www.cnblogs.com/csj007523/p/1151684.html