ASP.NET基本操作
3270 ワード
ASP.NET基本操作
N.1ページジャンプ
this.Response.Redirect("login_fail.htm");
新しいページを開くには、次の文を使用します.
ただし、IEがイジェクトウィンドウをブロックするプラグインを使用している場合は、ブロックされます.
N.2 JSPのようにHTMLページにC#コードを挿入する
まずcsでpublic型の変数を作成する
そのpage loadイベントで初期化
HTMLページに次のコードを挿入し、20行のテーブルを作成します.
N.3ページ間でパラメータを渡す
N.3.1文字列パラメータ(GET)
送信パラメータ
受信パラメータ
string s = Request.QueryString["parm1"];
中国語のパラメータでは、伝達後に文字列が切断される場合があります.解決方法は2つあります.第1の方法: パラメータ送信時にEncode
そしてパラメータ受信時にDecode第2の方法は、webを修正する.config(推奨)
N.3.2文字列パラメータ(POST)
POST方式で伝達されるパラメータは、以下の方式で受信する必要がある.
クライアントのパラメータ伝達方式を判断するには、システム変数Requestを使用する必要がある.ServerVariables["REQUEST_METHOD"],例:
N.3.3対象型
オブジェクト型パラメータを渡す場合は、Sessionシステム変数を使用します.
N.4複数のFrameを同時にリフレッシュ
N.5プログラム設計部
N.5.1クラスライブラリのインポート
次のクラスライブラリはデフォルトのインポートに属します.
N.5.2経路
Server.MapPath(".") C:/Inetpub/wwwrootなどの現在のサイトの実際の絶対パスを取得し、ファイルを生成する必要がある場合は、この絶対パスを使用する必要があります.
N.1ページジャンプ
this.Response.Redirect("login_fail.htm");
新しいページを開くには、次の文を使用します.
this.Response.Write("<script>window.open(/"login_fail.htm/");</script>");
ただし、IEがイジェクトウィンドウをブロックするプラグインを使用している場合は、ブロックされます.
N.2 JSPのようにHTMLページにC#コードを挿入する
まずcsでpublic型の変数を作成する
public int Lines;
そのpage loadイベントで初期化
this.Lines = 20;
HTMLページに次のコードを挿入し、20行のテーブルを作成します.
<table border="1" bordercolor="#990099" cellpadding="0" cellspacing="0">
<%
for(int i = 0; i < this.Lines; i++)
{
%>
<tr>
<td width="100%">
<%=i%>
</td>
</tr>
<%}%>
</table>
N.3ページ間でパラメータを渡す
N.3.1文字列パラメータ(GET)
送信パラメータ
<A href="test.aspx?parm1= " target="_blank" runat="server"> </A>
受信パラメータ
string s = Request.QueryString["parm1"];
中国語のパラメータでは、伝達後に文字列が切断される場合があります.解決方法は2つあります.
"PotoList.aspx?repairgroup_name=" + HttpUtility.UrlEncode(" '")
そしてパラメータ受信時にDecode
string name = HttpUtility.Decode(Request.QueryString["repairgroup_name"])
<globalization
requestEncoding="gb2312"
responseEncoding="gb2312"
/>
N.3.2文字列パラメータ(POST)
POST方式で伝達されるパラメータは、以下の方式で受信する必要がある.
Request.Form[" "]
クライアントのパラメータ伝達方式を判断するには、システム変数Requestを使用する必要がある.ServerVariables["REQUEST_METHOD"],例:
if(Request.ServerVariables["REQUEST_METHOD"] == "POST")
{
...
}else if(Request.ServerVariables["REQUEST_METHOD"] == "GET")
{
...
}
N.3.3対象型
オブジェクト型パラメータを渡す場合は、Sessionシステム変数を使用します.
//
Session["parm"] = arr;
//
ArrayList arr = Session["parm"] as ArrayList;
Session.Remove("parm");
N.4複数のFrameを同時にリフレッシュ
Response.Write("<script language=/"javascript/">parent.frames[/"wLeft/"].location=/"Group.aspx/"</script>");
Response.Write("<script language=/"javascript/">parent.frames[/"wRight/"].location=/"Group2.aspx/"</script>");
N.5プログラム設計部
N.5.1クラスライブラリのインポート
<%@ Import namespace="Microsoft.Win32" %>
次のクラスライブラリはデフォルトのインポートに属します.
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
N.5.2経路
Server.MapPath(".") C:/Inetpub/wwwrootなどの現在のサイトの実際の絶対パスを取得し、ファイルを生成する必要がある場合は、この絶対パスを使用する必要があります.