2004年07月07日

<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.0 Transitional//EN”>
<HTML>
<HEAD>
<TITLE> 清除html的垃圾代码</TITLE>
<script language=”javascript”>
    <!–
    function execRE(re,rp,content) {
        oReg=new RegExp(re,”ig”);
        r = content.replace(oReg, rp);
        return r;
    }
    function codeSweeper(content, mode)
    {
        switch(mode)
        {
            case “allhtml”:
                    // 清除所有html标签
                    content = execRE(“</?[^>]*>”, “”, content);
                    break;
                case “word”:
                    // 清除所有的xml标签
                    content = execRE(“<\\?xml[^>]*>”, “”, content);
                    // 清除所有的带名称空间的标签
                    content = execRE(“<\/?[a-z]+:[^>]*>”, “”, content);               
                    // 清除所有的class属性   
                    content = execRE(“(<[^>]+) class=[^ |^>]*([^>]*>)”, “$1 $2″, content);           
                    // 清除所有的style属性
                    content = execRE(“(<[^>]+) style=\”[^\"]*\”([^>]*>)”, “$1 $2″, content);
                    // 清除所有空的span标签
                    content = execRE(“<span[^>]*><\/span[^>]*>”, “”, content);                    
                    // 清除所有的多余span标签
                    content = execRE(“<span><span>”,”<span>”, content);                            
                    content = execRE(“</span></span>”,”</span>”, content);
                    // 清除所有的多余空白
                    content = execRE(“[ ]*>”, “>”, content);           
                    break;
                case “css”:
                    // 清除所有的class属性   
                    content = execRE(“(<[^>]+) class=[^ |^>]*([^>]*>)”, “$1 $2″, content);           
                    // 清除所有的style属性
                    content = execRE(“(<[^>]+) style=\”[^\"]*\”([^>]*>)”, “$1 $2″, content);
                    break;
                case “font”:
                    content = execRE(“</?font[^>]*>”, “”, content);
                    break;
                case “span”:
                    content = execRE(“</?span[^>]*>”,”",content);
                    break; 
                case “script”:
                    break; 
        }
        return content;
    }

    function onPaste() {
    }

    function PasteWordContent() {
        var oTextRange = editor.document.body.createTextRange() ;
        oTextRange.execCommand(“Paste”) ;

        CleanCode();
    }

    function Init()
    {
        editor.document.write(Code.value);
        editor.document.designMode=”On”;
        editor.document.onpaste = onPaste;
    }

    function getContent()
    {
        return editor.document.body.innerHTML;
    }

    function setContent(content)
    {
        editor.document.body.innerHTML = content;
        ViewCode();
    }

    function CleanCode()
    {
        setContent(codeSweeper(getContent(), cleanMode.options[cleanMode.selectedIndex].value));
    }

    function ViewCode()
    {
        Code.value = getContent();
    }

    // –>
</script>
</HEAD>

<BODY onload=”Init()”>

清除模式<select name=”cleanMode”>
    <option value=”allhtml”>所有html标签</option>
    <option value=”word” selected>word代码</option>
    <option value=”css”>样式表</option>
    <option value=”font”>font标签</option>
    <option value=”span”>span标签</option>
    <option value=”script”>不安全的script脚本</option>
</select>
<input type=”button” onclick=’CleanCode()’ value=”清除”/>
<input type=”button” onclick=’PasteWordContent()’ value=”粘贴代码(根据选择的模式自动清除垃圾代码)”/><br />
编辑器:<iframe  id=”editor”></IFRAME><p></p>
<textarea id=”Code” rows=”20″ cols=”50″>
<DIV align=center>
<TABLE class=MsoNormalTable style=”BORDER-RIGHT: medium none; BORDER-TOP: medium none; MARGIN: auto auto auto 14.4pt; BORDER-LEFT: medium none; BORDER-BOTTOM: medium none; BORDER-COLLAPSE: collapse; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 0cm 5.4pt 0cm 5.4pt; mso-border-insideh: .5pt solid windowtext; mso-border-insidev: .5pt solid windowtext” cellSpacing=0 cellPadding=0 border=1>
<TBODY>
<TR style=”page-break-inside: avoid”>
<TD style=”BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: windowtext 1pt solid; WIDTH: 495pt; PADDING-TOP: 0cm; BORDER-BOTTOM: windowtext 1pt solid; BACKGROUND-COLOR: transparent; mso-border-alt: solid windowtext .5pt” vAlign=top width=660 colSpan=2>
<H2 style=”MARGIN: 0cm 0cm 0pt”><SPAN lang=EN-US><FONT size=3>Page top</FONT></SPAN></H2></TD></TR>
<TR style=”HEIGHT: 193.3pt; page-break-inside: avoid”>
<TD style=”BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: #d4d0c8; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: windowtext 1pt solid; WIDTH: 126pt; PADDING-TOP: 0cm; BORDER-BOTTOM: windowtext 1pt solid; HEIGHT: 193.3pt; BACKGROUND-COLOR: transparent; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt” vAlign=top width=168>
<P class=MsoNormal style=”MARGIN: 0cm 0cm 0pt”><SPAN style=”FONT-SIZE: 12pt; FONT-FAMILY: 黑体; mso-ascii-font-family: ‘Times New Roman’”>学员手册</SPAN><SPAN lang=EN-US style=”FONT-SIZE: 12pt; mso-fareast-font-family: 黑体”><?xml:namespace prefix = o ns = “urn:schemas-microsoft-com:office:office” /><o:p></o:p></SPAN></P>
<P class=MsoNormal style=”MARGIN: 0cm 0cm 0pt”><SPAN style=”FONT-SIZE: 12pt; FONT-FAMILY: 黑体; mso-ascii-font-family: ‘Times New Roman’”>个人信息查询</SPAN><SPAN lang=EN-US style=”FONT-SIZE: 12pt; mso-fareast-font-family: 黑体”><o:p></o:p></SPAN></P>
<P class=MsoNormal style=”MARGIN: 0cm 0cm 0pt”><SPAN style=”FONT-SIZE: 12pt; FONT-FAMILY: 黑体; mso-ascii-font-family: ‘Times New Roman’”>清单教室</SPAN></P>
<P class=MsoNormal style=”MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0″><B><SPAN style=”FONT-FAMILY: 华文中宋; mso-ascii-font-family: ‘Times New Roman’; mso-hansi-font-family: ‘Times New Roman’”>理论学习篇</SPAN></B><B><SPAN lang=EN-US style=”mso-fareast-font-family: 华文中宋”><o:p></o:p></SPAN></B></P>
<P class=MsoNormal style=”MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0″><B><SPAN style=”FONT-FAMILY: 华文中宋; mso-ascii-font-family: ‘Times New Roman’; mso-hansi-font-family: ‘Times New Roman’”>实务学习篇</SPAN></B><B><SPAN lang=EN-US style=”mso-fareast-font-family: 华文中宋”><o:p></o:p></SPAN></B></P>
<P class=MsoNormal style=”MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 36.15pt; mso-char-indent-count: 4.0″><B><SPAN style=”FONT-SIZE: 9pt; COLOR: blue; FONT-FAMILY: 宋体; mso-bidi-font-size: 12.0pt; mso-ascii-font-family: ‘Times New Roman’; mso-hansi-font-family: ‘Times New Roman’”>招投标流程简介</SPAN></B><B><SPAN lang=EN-US style=”FONT-SIZE: 9pt; COLOR: blue; mso-bidi-font-size: 12.0pt”><o:p></o:p></SPAN></B></P>
<P class=MsoNormal style=”MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 36pt; mso-char-indent-count: 4.0″><SPAN style=”FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-bidi-font-size: 12.0pt; mso-ascii-font-family: ‘Times New Roman’; mso-hansi-font-family: ‘Times New Roman’”>完整工程实例详解</SPAN><SPAN lang=EN-US style=”FONT-SIZE: 9pt; mso-bidi-font-size: 12.0pt”><o:p></o:p></SPAN></P>
<P class=MsoNormal style=”MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 36pt; mso-char-indent-count: 4.0″><SPAN style=”FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-bidi-font-size: 12.0pt; mso-ascii-font-family: ‘Times New Roman’; mso-hansi-font-family: ‘Times New Roman’”>实务重难点分析</SPAN><SPAN lang=EN-US style=”FONT-SIZE: 9pt; mso-bidi-font-size: 12.0pt”><o:p></o:p></SPAN></P>
<P class=MsoNormal style=”MARGIN: 0cm 0cm 0pt”><SPAN style=”FONT-SIZE: 12pt; FONT-FAMILY: 黑体; mso-ascii-font-family: ‘Times New Roman’”>答疑室</SPAN><SPAN lang=EN-US style=”FONT-SIZE: 12pt; mso-fareast-font-family: 黑体”><o:p></o:p></SPAN></P>
<P class=MsoNormal style=”MARGIN: 0cm 0cm 0pt”><SPAN style=”FONT-SIZE: 12pt; FONT-FAMILY: 黑体; mso-ascii-font-family: ‘Times New Roman’”>资源库</SPAN><SPAN lang=EN-US style=”FONT-SIZE: 12pt; mso-fareast-font-family: 黑体”><o:p></o:p></SPAN></P>
<P class=MsoNormal style=”MARGIN: 0cm 0cm 0pt”><SPAN style=”FONT-SIZE: 12pt; FONT-FAMILY: 黑体; mso-ascii-font-family: ‘Times New Roman’”>评测中心</SPAN><SPAN lang=EN-US style=”FONT-SIZE: 12pt; mso-fareast-font-family: 黑体”><o:p></o:p></SPAN></P>
<P class=MsoNormal style=”MARGIN: 0cm 0cm 0pt”><SPAN style=”FONT-SIZE: 12pt; FONT-FAMILY: 黑体; mso-ascii-font-family: ‘Times New Roman’”>实战寻宝</SPAN><SPAN lang=EN-US style=”FONT-SIZE: 12pt; COLOR: green; mso-fareast-font-family: 黑体”><o:p></o:p></SPAN></P></TD>
<TD style=”BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: #d4d0c8; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: #d4d0c8; WIDTH: 369pt; PADDING-TOP: 0cm; BORDER-BOTTOM: windowtext 1pt solid; HEIGHT: 193.3pt; BACKGROUND-COLOR: transparent; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt” vAlign=top width=492>
<P class=MsoNormal style=”MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: center” align=center><SPAN style=”FONT-SIZE: 18pt; COLOR: blue; FONT-FAMILY: 华文新魏; mso-bidi-font-size: 15.0pt; mso-font-kerning: 7.5pt; mso-ascii-font-family: ‘Times New Roman’”>招投标流程简介</SPAN><SPAN lang=EN-US style=”FONT-SIZE: 18pt; COLOR: blue; mso-bidi-font-size: 15.0pt; mso-fareast-font-family: 华文新魏; mso-font-kerning: 7.5pt”><o:p></o:p></SPAN></P>
<P class=MsoNormal style=”MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 30pt; mso-char-indent-count: 2.0″><SPAN style=”FONT-SIZE: 15pt; COLOR: black; FONT-FAMILY: 楷体_GB2312; mso-font-kerning: 7.5pt; mso-ascii-font-family: ‘Times New Roman’”>本课程通过对清单模式下招标、投标业务流程的简单描述与说明,向您介绍招投标过程中各个步骤与环节的操作办法,从而加深您对“清单规范”的理解,帮助您熟悉招投标的业务流程。</SPAN><SPAN lang=EN-US style=”FONT-SIZE: 15pt; COLOR: black; mso-fareast-font-family: 楷体_GB2312; mso-font-kerning: 7.5pt”><o:p></o:p></SPAN></P>
<P class=MsoNormal style=”MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 24pt; TEXT-ALIGN: right; mso-char-indent-count: 2.0″ align=right><SPAN style=”FONT-SIZE: 12pt; COLOR: green; FONT-FAMILY: 黑体; mso-bidi-font-size: 15.0pt; mso-font-kerning: 7.5pt; mso-ascii-font-family: ‘Times New Roman’”>开始学习</SPAN><SPAN lang=EN-US style=”FONT-SIZE: 12pt; COLOR: green; mso-fareast-font-family: 黑体”><o:p></o:p></SPAN></P></TD></TR>
<TR style=”page-break-inside: avoid; mso-yfti-lastrow: yes”>
<TD style=”BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: #d4d0c8; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0cm; BORDER-LEFT: windowtext 1pt solid; WIDTH: 495pt; PADDING-TOP: 0cm; BORDER-BOTTOM: windowtext 1pt solid; BACKGROUND-COLOR: transparent; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt” vAlign=top width=660 colSpan=2>
<P class=MsoNormal style=”MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: center” align=center><B style=”mso-bidi-font-weight: normal”><SPAN lang=EN-US style=”FONT-SIZE: 12pt”>Page bottom</SPAN></B></P></TD></TR></TBODY></TABLE></DIV>
<P class=MsoNormal style=”MARGIN: 0cm 0cm 0pt”><SPAN lang=EN-US><o:p> </o:p></SPAN></P>
<P class=MsoNormal style=”MARGIN: 0cm 0cm 0pt”><SPAN lang=EN-US><o:p> </o:p></SPAN></P>
</textarea>
<input type=”button” onclick=’ViewCode()’ value=”看代码”/>
</BODY>
</HTML>

 

2004年06月23日

if (!IsPostBack)
   {

    string strConnection = null;
    string strSQL = null;
    strConnection = “Provider=Microsoft.Jet.OleDb.4.0;Data Source=”+Server.MapPath(“../database/database.mdb”);
    strSQL = “select ClassID,ClassName from [system_NewsClass] where ParentClassID=0″;

    OleDbConnection myOleDbConnection = new OleDbConnection(strConnection);
    OleDbDataAdapter myOleDbDataAdapter = new OleDbDataAdapter(strSQL,myOleDbConnection);
    DataSet myDataSet = new DataSet();
    myOleDbDataAdapter.Fill(myDataSet,”system_NewsClass”);
    ddlParentClassID.DataSource = myDataSet.Tables["system_NewsClass"];
    ddlParentClassID.DataValueField = myDataSet.Tables["system_NewsClass"].Columns["ClassID"].Caption;
    ddlParentClassID.DataTextField =  myDataSet.Tables["system_NewsClass"].Columns["ClassName"].Caption;
    ddlParentClassID.DataBind();
    ddlParentClassID.Items.Insert(0,new ListItem(“一级类别”,”0″));
    myOleDbConnection.Close();
   }

2004年06月22日

  <SCRIPT language=Javascript><!– // load htmlarea
_editor_url = “”;                     // URL to htmlarea files
var win_ie_ver = parseFloat(navigator.appVersion.split(“MSIE”)[1]);
if (navigator.userAgent.indexOf(‘Mac’)        >= 0) { win_ie_ver = 0; }
if (navigator.userAgent.indexOf(‘Windows CE’) >= 0) { win_ie_ver = 0; }
if (navigator.userAgent.indexOf(‘Opera’)      >= 0) { win_ie_ver = 0; }
if (win_ie_ver >= 5.5) {
  document.write(‘<scr’ + ‘ipt src=”‘ +_editor_url+ ‘editor.js”‘);
  document.write(‘ language=”Javascript”></scr’ + ‘ipt>’); 
} else { document.write(‘<scr’+'ipt>function editor_generate() { return false; }</scr’+'ipt>’); }
// –></SCRIPT>
<TEXTAREA id=mytextarea style=”WIDTH: 800px; HEIGHT: 400px” runat=”server”>         </TEXTAREA>
<SCRIPT language=javascript>
editor_generate(‘<% Response.Write(mytextarea.ClientID); %>’); ;
</SCRIPT>

轻松将html转化为.net了

看来我要学学基础了!
 

2004年06月17日

Page_Load中添加

btnAdd.Attributes.Add(“OnMouseOver”,”this.className=’coolButtonUp’”);
btnAdd.Attributes.Add(“OnMouseOut”,”this.className=’coolButton’”);
btnAdd.Attributes.Add(“OnMouseDown”,”this.className=’coolButtonDown’”);
btnAdd.Attributes.Add(“OnMouseUp”,”this.className=’coolButtonUp’”);

2004年06月15日

.cs

   string strConnection = null;
   string strSQL = null;

   strConnection = “Provider=Microsoft.Jet.OleDb.4.0;Data Source=”+Server.MapPath(“./database/database.mdb”);
   strSQL = “select * from [system_Class]“;

   OleDbConnection myOleDbConnection = new OleDbConnection(strConnection);
   OleDbDataAdapter myOleDbDataAdapter = new OleDbDataAdapter(strSQL,myOleDbConnection);
   DataSet myDataSet = new DataSet();
   myOleDbDataAdapter.Fill(myDataSet,”system_Class”);
   
   Repeater1.DataSource = myDataSet.Tables["system_Class"];
   Repeater1.DataBind();
   this.Response.Write(Repeater1.Items.Count);
   myOleDbConnection.Close();

 

.aspx



<%# DataBinder.Eval(Container.DataItem, "ClassName") %>

<%# DataBinder.Eval(Container.DataItem, "ClassName") %><%# DataBinder.Eval(Container.DataItem, "ClassName") %><%# DataBinder.Eval(Container.DataItem, "ClassName") %><%# DataBinder.Eval(Container.DataItem, "ClassName") %><%# DataBinder.Eval(Container.DataItem, "ClassName") %><%# DataBinder.Eval(Container.DataItem, "ClassName") %><%# DataBinder.Eval(Container.DataItem, "ClassName") %>

   string strConnection = “Provider=Microsoft.Jet.OleDb.4.0;Data Source=”+Server.MapPath(“../database/database.mdb”);
   string strSQL = “select * from [system_Class]“;

   OleDbConnection myOleDbConnection = new OleDbConnection(strConnection);
   OleDbDataAdapter myOleDbDataAdapter = new OleDbDataAdapter(strSQL,myOleDbConnection);
   DataSet myDataSet = new DataSet();
   myOleDbDataAdapter.Fill(myDataSet,”system_Class”);
   int myCount = myDataSet.Tables[0].Rows.Count;
   myOleDbConnection.Close();
   this.Response.Write(myCount);

2004年06月14日

using System.Drawing.Imaging;

  private void Page_Load(object sender, System.EventArgs e)
  {
   // 在此处放置用户代码以初始化页面
   //RndNum是一个自定义函数
   string VNum=RndNum(4); //这里的数字4代表显示的是4位的验证字符串!
   Session["VNum"]=VNum;
   ValidateCode(VNum);
  }

  //生成图像函数
  private void ValidateCode(string VNum)
  {
   int Gheight=(int)(VNum.Length * 7);
   //gheight为图片宽度,根据字符长度自动更改图片宽度
   System.Drawing.Bitmap Img = new System.Drawing.Bitmap(Gheight,12);
   Graphics g = Graphics.FromImage(Img);
   g.DrawString(VNum,new System.Drawing.Font(“宋体”,9),new System.Drawing.SolidBrush(Color.Red),0,0);
   //在矩形内绘制字串(字串,字体,画笔颜色,左上x.左上y)
   System.IO.MemoryStream ms=new System.IO.MemoryStream();
   Img.Save(ms,System.Drawing.Imaging.ImageFormat.Png);
   Response.ClearContent(); //需要输出图象信息 要修改HTTP头
   Response.ContentType=”image/Png”;
   Response.BinaryWrite(ms.ToArray());
   g.Dispose();
   Img.Dispose();
   Response.End();
  }

  //生成随机数函数中从Vchar数组中随机抽取
  //字母区分大小写
  public string RndNum(int VcodeNum)
  {
   string Vchar = “0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,W,X,Y,Z” ;
  
   string[] VcArray = Vchar.Split(‘,’) ;
   string  VNum = “” ;//由于字符串很短,就不用StringBuilder了
   int temp = -1 ;//记录上次随机数值,尽量避免生产几个一样的随机数

   //采用一个简单的算法以保证生成随机数的不同
   Random rand =new Random();
   for ( int i = 1 ; i < VcodeNum+1 ; i++ )
   {   
    if ( temp != -1)
    {
     rand =new Random(i*temp*unchecked((int)DateTime.Now.Ticks));
    }   
    //int t =  rand.Next(35) ;
    int t=rand.Next(35);
    if (temp != -1 && temp == t)
    {
     return RndNum( VcodeNum );
    }
    temp = t  ;
    VNum += VcArray[t];

   }
   return VNum ;
  }

using System.Data.SqlClient;

//using System.Data.OleDb;

   SqlDataReader myDataReader = null;
   //OleDbDataReader myDataReader = null;
   string strConnection = null;
   string strSQL = null;

   strConnection = “server=127.0.0.1;uid=sa;pwd=sa;database=test”;
   //strConnection = “Provider=Microsoft.Jet.OleDb.4.0;Data Source=”+Server.MapPath(“./database/test.mdb”);
   strSQL = “SELECT UserID, UserName, UserPassword FROM [system_User]“;
   
   SqlConnection mySqlConnection = new SqlConnection(strConnection);
   //OleDbConnection myOleDbConnection = new OleDbConnection(strConnection);
   SqlCommand mySqlCommand = new SqlCommand(strSQL, mySqlConnection);
   //OleDbCommand myOleDbCommand = new OleDbCommand(strSQL, myOleDbConnection);
   mySqlConnection.Open();
   //myOleDbConnection.Open();

   myDataReader = mySqlCommand.ExecuteReader();
   DataGrid1.DataSource = myDataReader;
   DataGrid1.DataBind();
   if (myDataReader.Read())
   {
    lblUserID.Text = Convert.ToString(myDataReader["UserID"]);
    lblUserName.Text=Convert.ToString(myDataReader["UserName"]);
    lblUserPassword.Text=Convert.ToString(myDataReader["UserPassword"]);
   }
   myDataReader.Close();
   mySqlConnection.Close();
   //myOleDbConnection.Close();