04 Mar 2004

MessageBox Control in ASP.NET

在ASP.NET里实现MessageBox

http://www.microsoft.com/india/msdn/articles/119.aspx?










ShowMessageAtStartup
 
This control is used to show message at startup of the page. For example, if you want to inform the user with some information using message box after the post back. Then you can use this control. This control has following two properties,
 



MessageText: This property is used to set the Message which is showed in the message box.
Enabled: This property is used for enabling or disabling this control depending upon the
requirement.

 
MessageAtSubmit
 
This control is used to show alert message or confirm message box when the page is submitted. For example, when the user is pressing a button to delete a record. During that time, if you want to ask the user for confirmation. Then you can use this control. This control has following properties,
 








MessageText: This property is used to set the Message which is showed in the message box.
Enabled: This property is used for enabling or disabling this control depending upon the
requirement.
IsConfirmMessage: This property is used to mention whether it is confirmation message box or alert message box.
ConfirmMessagePassClientScript: This property is used to mention the client side script which has to executed if the confirmation message return true. i.e. when users presses ok button. This property will be used only when isConfirmmessage property is set to true
ConfirmMessageFailClientScript: This property is used to mention the client side script which
has to executed if the confirmation message return false. i.e. when users presses
cancel button. This property will be used only when isConfirmmessage property
is set to true.

23 Feb 2004

用Asp.Net抓取web页面

演示:
http://www.github.com/demo/286.aspx


代码高亮显示(HightLight in Source Code Viewer)


http://www.github.com/code/default.aspx/S7s2zPJbeI9PJA/OK
HpAVwVaUEhf02EgEOgeB3Yd5Z7fLL3ZNgdv7XIqertUOYm9kbQ62
LshbJBwvWPBBYa4EyVMhvMhyEDPH8chU5ornn8=.Aspx

<html>
<head>
 

<SCRIPT runat="server">
  void Page_Load(Object sender, EventArgs e) {

    WebRequest req = WebRequest.Create("http://www.im286.com/index.php");
 string urliii="src="; //图片使用绝对连接
 urliii+="http://www.im286.com/";
    try {
        WebResponse result = req.GetResponse();
        Stream ReceiveStream = result.GetResponseStream();

        Byte[] read = new Byte[512];
        int bytes = ReceiveStream.Read(read, 0, 512);

        lblHTML.Text = "";
        while (bytes > 0)
        {

          // 注意:
          // 下面假定响应使用 gb2312 作为编码方式。
          // 如果内容以 ANSI 代码页形式(例如,932)发送,则使用类似下面的语句:
          //Encoding encode = System.Text.Encoding.GetEncoding("shift-jis");
          Encoding encode = System.Text.Encoding.GetEncoding("gb2312");
          lblHTML.Text = lblHTML.Text + encode.GetString(read, 0, bytes);
   
          bytes = ReceiveStream.Read(read, 0, 512);
   
        }
    } catch(Exception) {
        lblHTML.Text = "检索页时出错";
    }
 lblHTML.Text = lblHTML.Text.Replace("src=",""+urliii+"");
 lblHTML.Text = lblHTML.Text.Replace("\"","");
  }
</SCRIPT>
</head>

<body>
  <form method="post" action="Webrequest.aspx" runat="server">
   
    <asp:Label runat=server ID="lblHTML" Rows="30" Cols="80" EnableViewState="false"  Wrap="True"></asp:Label>
  </form>

</body>
</html>

<%@ Page language="C#" Trace="True" %>
<%@ Import Namespace="System.Net" %>
<%@ Import Namespace="System.IO" %>

23 Feb 2004

用Asp.Net抓取web页面

演示:
http://www.github.com/demo/286.aspx


代码高亮显示(HightLight in Source Code Viewer)


http://www.github.com/code/default.aspx/S7s2zPJbeI9PJA/OK
HpAVwVaUEhf02EgEOgeB3Yd5Z7fLL3ZNgdv7XIqertUOYm9kbQ62
LshbJBwvWPBBYa4EyVMhvMhyEDPH8chU5ornn8=.Aspx

<html>
<head>
 

<SCRIPT runat="server">
  void Page_Load(Object sender, EventArgs e) {

    WebRequest req = WebRequest.Create("http://www.im286.com/index.php");
 string urliii="src="; //图片使用绝对连接
 urliii+="http://www.im286.com/";
    try {
        WebResponse result = req.GetResponse();
        Stream ReceiveStream = result.GetResponseStream();

        Byte[] read = new Byte[512];
        int bytes = ReceiveStream.Read(read, 0, 512);

        lblHTML.Text = "";
        while (bytes > 0)
        {

          // 注意:
          // 下面假定响应使用 gb2312 作为编码方式。
          // 如果内容以 ANSI 代码页形式(例如,932)发送,则使用类似下面的语句:
          //Encoding encode = System.Text.Encoding.GetEncoding("shift-jis");
          Encoding encode = System.Text.Encoding.GetEncoding("gb2312");
          lblHTML.Text = lblHTML.Text + encode.GetString(read, 0, bytes);
   
          bytes = ReceiveStream.Read(read, 0, 512);
   
        }
    } catch(Exception) {
        lblHTML.Text = "检索页时出错";
    }
 lblHTML.Text = lblHTML.Text.Replace("src=",""+urliii+"");
 lblHTML.Text = lblHTML.Text.Replace("\"","");
  }
</SCRIPT>
</head>

<body>
  <form method="post" action="Webrequest.aspx" runat="server">
   
    <asp:Label runat=server ID="lblHTML" Rows="30" Cols="80" EnableViewState="false"  Wrap="True"></asp:Label>
  </form>

</body>
</html>

<%@ Page language="C#" Trace="True" %>
<%@ Import Namespace="System.Net" %>
<%@ Import Namespace="System.IO" %>

12 Feb 2004

一个不错的代码编辑工具

CrimSon Editer

http://www.crimsoneditor.com/

我用它因为它体积小 启动迅速 最大的优点是免费
支持许多常用代码的语法高亮显示.
可以在这里下载到C#的代码高亮显示文件
http://www.crimsoneditor.com/board/CrazyWWWBoard.cgi?db=user0&mode=read&num=99&page=1&ftype=6&fval=c%23&backdepth=1

还有其他好的编辑工具都列在这里了:
http://www.crimsoneditor.com/english/editors.html

09 Feb 2004

分页存储过程

搞了一中午终于可以用了 但不知道效率如何.郁闷的是我要用php去调用它

  /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    CopyRight:   ******
    CreateData:   2004-02-09
    Language:   MS SQL SERVER 存储过程
    AuthorName:  Meibo Wu

    实现功能:   分页显示当用户选择了图片大分类时(按手机)的数据
    参数说明:   @bigtype为大分类
    @gid为传入的图片类型           
        $PageSize为每页显示的记录数量
    @pageindex为当前页码                             
    LastUpdate:            
    ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
CREATE procedure sms_img_page_no_smalltype
(
 @bigtype nvarchar(20),
 @gid int,
 @pagesize int,
 @pageindex int
)
as
set nocount on
 declare @LikeBigType nvarchar(20)
 declare @PageLowerBound int
 declare @PageUpperBound int
 declare @indextable table(id int identity(1,1),nid int)
  set @PageLowerBound=(@pageindex-1)*@pagesize
  set @PageUpperBound= @PageLowerBound+@pagesize
  set @LikeBigType= @bigtype+'%'
  set rowcount @PageUpperBound
 insert into @indextable(nid)
  select  a.col_id
   from web_sms_data_img as a join web_sms_data_mobile as q
   on a.col_mobile_type=q.col_mobile_type
   where
a.col_img_group=@gid
    and q.col_mobile_comment  like @LikeBigType
   order by a.col_id desc 
 /*
 select  @LikeBigType
 select * from @indextable 
 */
 select q.col_mobile_comment,
  a.col_id,
  a.col_img_hits,
  a.col_img_dir,
  a.col_img_name
  from web_sms_data_img as a join web_sms_data_mobile as q
   on a.col_mobile_type=q.col_mobile_type
    join @indextable  as p
    on a.col_id=p.nid
  where p.id>@PageLowerBound and p.id<
=@PageUpperBound
   and
a.col_img_group=@gid
   and q.col_mobile_comment like @LikeBigType
 
 order by p.id

set nocount off
GO

09 Feb 2004

分页存储过程

搞了一中午终于可以用了 但不知道效率如何.郁闷的是我要用php去调用它

  /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    CopyRight:   ******
    CreateData:   2004-02-09
    Language:   MS SQL SERVER 存储过程
    AuthorName:  Meibo Wu

    实现功能:   分页显示当用户选择了图片大分类时(按手机)的数据
    参数说明:   @bigtype为大分类
    @gid为传入的图片类型           
        $PageSize为每页显示的记录数量
    @pageindex为当前页码                             
    LastUpdate:            
    ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
CREATE procedure sms_img_page_no_smalltype
(
 @bigtype nvarchar(20),
 @gid int,
 @pagesize int,
 @pageindex int
)
as
set nocount on
 declare @LikeBigType nvarchar(20)
 declare @PageLowerBound int
 declare @PageUpperBound int
 declare @indextable table(id int identity(1,1),nid int)
  set @PageLowerBound=(@pageindex-1)*@pagesize
  set @PageUpperBound= @PageLowerBound+@pagesize
  set @LikeBigType= @bigtype+'%'
  set rowcount @PageUpperBound
 insert into @indextable(nid)
  select  a.col_id
   from web_sms_data_img as a join web_sms_data_mobile as q
   on a.col_mobile_type=q.col_mobile_type
   where
a.col_img_group=@gid
    and q.col_mobile_comment  like @LikeBigType
   order by a.col_id desc 
 /*
 select  @LikeBigType
 select * from @indextable 
 */
 select q.col_mobile_comment,
  a.col_id,
  a.col_img_hits,
  a.col_img_dir,
  a.col_img_name
  from web_sms_data_img as a join web_sms_data_mobile as q
   on a.col_mobile_type=q.col_mobile_type
    join @indextable  as p
    on a.col_id=p.nid
  where p.id>@PageLowerBound and p.id<
=@PageUpperBound
   and
a.col_img_group=@gid
   and q.col_mobile_comment like @LikeBigType
 
 order by p.id

set nocount off
GO

09 Feb 2004

顺便发现一bug??

在这个http://www.cnblogs.com/huobazi/archive/2004/02/09/1053.aspx 里有一句
a.col_img_group=@gid

被DotText当成mailto 自动加上了mailto连接

04 Feb 2004

使网页中的元素可编辑

net_lover的文章里找到了答案.

http://www.csdn.net/Develop/Read_Article.asp?Id=4405


代码如下:
<HTML>
<HEAD>
</HEAD>
<BODY>
<DIV ID=“oDiv”>TEST—TEST—TEST 您可以在这里编辑文字!</DIV>
<SCRIPT>
<!–
oDiv.contentEditable = true;
// –>
</SCRIPT>
</BODY>
</HTML>

04 Feb 2004

使网页中的元素可编辑

net_lover的文章里找到了答案.

http://www.csdn.net/Develop/Read_Article.asp?Id=4405


代码如下:
<HTML>
<HEAD>
</HEAD>
<BODY>
<DIV ID=“oDiv”>TEST—TEST—TEST 您可以在这里编辑文字!</DIV>
<SCRIPT>
<!–
oDiv.contentEditable = true;
// –>
</SCRIPT>
</BODY>
</HTML>

04 Feb 2004

域名Whois信息查询(ASP.NET+C#)

去年写的了,是从点缀的博客学来的
看演示请点这里:http://www.github.com/whois.aspx
代码如下:
<% @Page Language="C#" %>
<% @Import Namespace="System.Net.Sockets" %>
<% @Import Namespace="System.Text" %>
<% @Import Namespace="System.IO" %>
<html>
<head>
<title>.Com/.Net/.Org/.Cn 域名Whois信息查询</title>
<meta name="keywords" content=".Com,.Net,.Org,.Cn 域名Whois信息查询">
<meta name="generator" content=".Com/.Net/.Org,.Cn 域名Whois信息查询">
<meta name="description" content=".Com/.Net/.Org,.Cn 域名Whois信息查询">
<style>
<!--
body,input{
        font-family: Tahoma, Verdana; color: #004080; font-size: 12px        
        }
a:link,a:visited{
        text-decoration: none; color: #004080
        }
-->
</style>
</head>
<body>
<form id="fmQuery" runat="server">
&nbsp;要查询的域名域名:
www.<asp:TextBox id="txtDomain" width="100" value="ASPXBOY.COM" runat="server" />
&nbsp; <asp:Button id="btnQuery" OnClick="btn_click"
text="查询!" runat="server" />(只能查询.Com/.Net/.Org/.Cn 域名Whois的信息)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href ="WhoisCode.htm" title="View the source code here!">源代码在这里</a>
<BR><HR width="550" height="1" align="left"><BR>
<asp:label id="lblResult" runat="server" />
</form>
</body>
</html>
<script language="C#" runat="server">
void btn_click(Object sender, EventArgs e)
{
String strServer;
String strDomain = txtDomain.Text;
String strServerCom = "whois.networksolutions.com";
String strServerCN = "whois.cnnic.net.cn";
String strResponse;
string[] arrDomain = strDomain.Split('.');
if (arrDomain[1].ToUpper()=="CN")
{
       
        strServer=strServerCN;
}
else
{
        strServer=strServerCom;
}

bool blSuccess = IsWhosisSuccess(strDomain, strServer, out strResponse);
if (blSuccess)
{
lblResult.Text = strResponse;
}
else
{
lblResult.Text = "查找失败....";
}
}
bool IsWhosisSuccess(String strDomain, String strServer,
                   out String strResponse)
{
  strResponse = "none";
  bool blSuccess = false;
  TcpClient tcpc = new TcpClient();
  try
  {
    tcpc.Connect(strServer, 43);
  }
  catch(SocketException ex)
  {
    strResponse = "连接不到该 Whois server,请稍后再试。";
    return false;
  }

  strDomain += "\r\n";
  Byte[] arrDomain = Encoding.UTF8.GetBytes(strDomain.ToCharArray());
  try
  {
        Stream s = tcpc.GetStream();
        s.Write(arrDomain, 0, strDomain.Length);
       
        StreamReader sr = new StreamReader(tcpc.GetStream(), Encoding.UTF8);
        StringBuilder strBuilder = new StringBuilder();
        string strLine = null;

        while (null != (strLine = sr.ReadLine()))
        {
                strBuilder.Append(strLine+"<br>");
        }
        tcpc.Close();
               
        blSuccess = true;
        string my="Go to Huobazi's WebSite:<a href=\"http://www.github.com\" title=\".Net男孩社区\">www.github.Com</a><br>";
        strResponse = strBuilder.ToString()+my;  }
  catch(Exception e)
  {
        strResponse = e.ToString();
  }
  
  return blSuccess;
}
  </script>