2

来源:互联网 发布:吉首大学教务网络缴费 编辑:程序博客网 时间:2024/04/18 19:25

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;
using System.Text.RegularExpressions;

namespace WebSample
{
 /// <summary>
 /// ContentPage の概要の説明です。
 /// </summary>
 public class ContentPage : System.Web.UI.Page
 {
  protected System.Web.UI.WebControls.Panel Panel1;
  protected System.Web.UI.WebControls.TextBox TextBox1;
 
  private void Page_Load(object sender, System.EventArgs e)
  {
   // ページを初期化するユーザー コードをここに挿入します。
   GetHtml();
  }

  #region Web フォーム デザイナで生成されたコード
  override protected void OnInit(EventArgs e)
  {
   //
   // CODEGEN: この呼び出しは、ASP.NET Web フォーム デザイナで必要です。
   //
   InitializeComponent();
   base.OnInit(e);
  }
  
  /// <summary>
  /// デザイナ サポートに必要なメソッドです。このメソッドの内容を
  /// コード エディタで変更しないでください。
  /// </summary>
  private void InitializeComponent()
  {   
   this.Load += new System.EventHandler(this.Page_Load);

  }
  #endregion

  private void GetHtml()
  {
   //
   int i,pp;
   //
   i=0;   

   //
   string pa=Request.Params["page"];
   if(pa=="" || pa==null)
    pa="1";
   pp=Convert.ToInt32(pa);

   //
   string articletxt="40分、ACCは123便と他機との交信を分けるため、123便専用の周波数が準備され、123便にその周波数に変える[page]よう求めたが返答は無かった。42分、123便 ... そして20時30分、関係機関は[page]山火事が確認された長野県南佐久郡近郊が123便の正式な墜落地点とした。";
   string[] resultString=Regex.Split(articletxt,@"/[page/]",RegexOptions.IgnoreCase);
   
   TextBox1.Text = resultString[pp-1];

   string htmldf="";//
   if(resultString.Length>1)//
   {
    if(pp<=1)//
     htmldf+="[previous]";
    else
     htmldf+="<a href=?id="+i+"&page="+(pp-1)+">[previous]</a>";
    for(i=1;i<=resultString.Length;i++)
    {
     if(i==pp)//     
      htmldf+="<b>["+i+"]</b> ";     
     else
      htmldf+="<a href=?id="+i+"&page="+i+">["+i+"]</a> ";
    }
    if(pp+1>resultString.Length)//
     htmldf+="[next]";
    else
     htmldf+="<a href=?id="+i+"&page="+(pp+1)+">[next]</a></p>";
   }

   Response.Write(htmldf);

  }

  
 }
}
 

原创粉丝点击