不进则退

Roger's blog @cnblogs

导航

统计

与我联系

搜索

 

常用链接

留言簿

随笔分类

随笔档案

我的网站

最新评论

阅读排行榜

评论排行榜

2005年11月1日 #

[过时的消息]VS2005 Shipped!

Visual Studio 2005的各个版本都陆续发布了,如果之前有安装过CTP、beta版本,最好在安装前把先前的版本都卸载掉,以免不必要的麻烦。有个专门的卸载工具,下载地址是:

http://go.microsoft.com/fwlink/?LinkId=47598

posted @ 2005-11-01 13:37 Roger Wo 阅读(638) | 评论 (1)编辑

2005年10月22日 #

用Atlas来实现一个基于AJAX的无刷新Chatroom

Atlas是微软提供的一个AJAX工具包,封装了实现AJAX的所需的Java Script,使用起来非常简单,可以直接调用Web Service方法,然后通过Asynchronous Call的方式回调给客户端script,我用Atlas写了个简单的基于AJAX的无刷新chatroom:

Atlas Chatroom
http://www.worong.com/atlaschat/

为了引用Web Service,首先要在页面中添加以下客户端脚本:

<script language="JavaScript" src="ChatService.asmx/js"/>

用来显示和添加message的调用如下,对于每个方法的调用需要三个参数,分别是:Web Service方法的参数、调用成功后的回调函数、调用超时的回调函数。
 
function GetMsg() {
    AtlsChat.ChatService.GetConversation(
    
"",     //params
    OnComplete,     //Complete event
    OnTimeout       //Timeout event
    );
    
    
return false;
}


function Add() {
    document.getElementById('info').innerHTML 
= '<span style="background-color: yellow">&nbsp;posting&nbsp;</span>';
    AtlsChat.ChatService.Add(
    document.getElementById('inputName').value.replace('\t','
&nbsp;&nbsp;&nbsp;')+'\t'+ document.getElementById('inputMsg').value.replace('\t','&nbsp;&nbsp;&nbsp;'),
    GetMsg,
    OnTimeout
    );
    
    
return false;
}

    
function OnComplete(result) 
    
{
        document.getElementById('msg').innerHTML 
= result;
            
        document.getElementById('info').innerHTML 
= "";
    }


    
function OnTimeout(result) 
    
{
        document.getElementById('info').innerHTML 
= "time out";
    }


最后,需要在页面中引用Atlas提供的几个js:

<atlas:Script ID="Script1" runat="server" Path="~/ScriptLibrary/AtlasCompat.js" Browser="Mozilla" />
    
<atlas:Script ID="Script2" runat="server" Path="~/ScriptLibrary/AtlasCompat.js" Browser="Firefox" />
    
<atlas:Script ID="Script3" runat="server" Path="~/ScriptLibrary/AtlasCompat.js" Browser="AppleMAC-Safari" />
    
<atlas:Script ID="Script4" runat="server" Path="~/ScriptLibrary/AtlasCore.js" />
    
<atlas:Script ID="Script5" runat="server" Path="~/ScriptLibrary/AtlasCompat2.js" Browser="AppleMAC-Safari" />

 
<script type="text/xml-script">
        
<page xmlns:script="http://schemas.microsoft.com/xml-script/2005">
            
<references>
                
<!-- Repath the following src attributes, using regular client relative paths as necessary -->
                
<add src="ScriptLibrary/AtlasUI.js" />
                
<add src="ScriptLibrary/AtlasControls.js" />
            
</references>
            
<components>
            
</components>
        
</page>
   
</script>

Atlas的官方网站是http://beta.asp.net/default.aspx?tabindex=7&tabid=47,虽然提供了对非IE浏览器的支持,但是在Firefox中更新div会有刷新的感觉,在Mac的Safari上也根本就不work

posted @ 2005-10-22 17:24 Roger Wo 阅读(3915) | 评论 (8)编辑

2005年10月19日 #

Passion回来了

痛定思痛,这个blog不能再荒废了

posted @ 2005-10-19 00:40 Roger Wo 阅读(135) | 评论 (2)编辑

2005年4月12日 #

SQL Server / Access数据类型对照表

SQL Server and Access data types.
SQL Server 7 data type ADO data type Enum value
binary adVarBinary
bit adBoolean
char adChar
datetime adDate
decimal adNumeric
float adDouble
int adInteger
money adCurrency
nchar adWChar
ntext adLongVarChar
numeric adNumeric
nvarchar adVarWChar
real adSingle
smalldatetime adDate
smallint adSmallInt
text adLongVarChar
timestamp adBinary
tinyint adUnsignedTinyInt
UniqueIdentifier adGUID
varBinary adVarBinary
varChar adVarChar

posted @ 2005-04-12 14:33 Roger Wo 阅读(923) | 评论 (0)编辑

2005年4月5日 #

VS.NET Add-in在Design time获取控件值

客户要写一个Visual Studio .NET的Add-in,需要在design time获取form上控件的值,以下是用Reflection的做法

     

       Dim win As Window = applicationObject.ActiveWindow
            
Dim d As ComponentModel.Design.IDesignerHost = win.Object
            iss 
= d.GetService(GetType(ComponentModel.Design.ISelectionService))
            
Dim c As ComponentModel.Component = iss.PrimarySelection
            
Dim pi As Reflection.PropertyInfo = CObj(c).GetType().GetProperty("Visible")
            
            
Dim val As Object = pi.GetValue(c, Nothing)
            
Dim tc As System.ComponentModel.TypeConverter = ComponentModel.TypeDescriptor.GetConverter(val)
            
MsgBox(c.Site.Name & "." & pi.Name & " = " & tc.ConvertToString(val))


这样做有一个问题,当我要取TextBox.Visible这类属性的时候,返回值永远为true,因为reflect的是designer中的textbox对象,它的visible值永远为true。正确的做法是通过PropertyDescriptorCollection来读取Properties window里面的值,代码如下:

  
   
           
'query Properties
            Dim properties As System.ComponentModel.PropertyDescriptorCollection
            properties 
= System.ComponentModel.TypeDescriptor.GetProperties(c)
            
Dim prop As System.ComponentModel.PropertyDescriptor
            prop 
= properties("Visible")
            
MsgBox(c.Site.Name & "." & prop.Name & " = " & prop.GetValue(c))

本贴子以“现状”提供且没有任何担保,同时也没有授予任何权利

posted @ 2005-04-05 14:44 Roger Wo 阅读(814) | 评论 (2)编辑

2005年3月2日 #

Visual Studio .NET 2002 Service Pack 1 出来了

下载地址:
http://www.microsoft.com/downloads/details.aspx?FamilyId=C41D8159-B42F-4D06-A797-E510494976EE&displaylang=en


需要VS.NET 2003 SP1的同志再等等,马上就会有了。

posted @ 2005-03-02 11:23 Roger Wo 阅读(1337) | 评论 (4)编辑

2005年2月22日 #

在.NET程序中控制系统音量

     摘要: 在windows下控制系统音量,需要通过使用win32的WDM audio components(winmm.dll)来实现,为了方便起见,将其封装到了一个AudioMixerHelper类中,可以直接通过GetVolume()和SetVolume方法来改变音量。 using System; using System.Runtime.InteropServices; ... 阅读全文

posted @ 2005-02-22 16:43 Roger Wo 阅读(1726) | 评论 (7)编辑

2005年2月7日 #

Winform下通过控件名称来获取控件

以前一直在Webform下用Control.FindControl(string)方法来获取页面上的某个控件,可是Winform下面的ControlCollection却没有提供FindControl的方法:
http://msdn.microsoft.com/library/en-us/cpref/html/frlrfsystemwindowsformscontrolcontrolcollectionmemberstopic.asp?frame=true

没办法,只好自己建一个Hash表来实现。


        //Populate data

        
ushort[] mydata = new ushort[]{111,222,333,444,555,666,777,888,999,1000};

                        

                        
//Create a Hashtable reference to all the TextBoxes

                        Hashtable htTextBox 
= new Hashtable();

                        
foreach (Control c in this.Controls)

                        
{

                                
if (c.GetType().ToString() == "System.Windows.Forms.TextBox")

                                        htTextBox.Add(c.Name,c);

                        }


                        
//Search TextBox from Hashtable and evalute it.

                        
for (int i=0;i<10;i++)

                        
{

                                TextBox t;

                                t 
= (TextBox)htTextBox["textBox"+(i+1).ToString()];

                                t.Text 
= mydata[i].ToString();

                        }
 

查了下.NET Framework 2.0的文档,果然发现.NET 2.0中给Control.ControlCollection对象增加了名为Find的方法...
http://msdn2.microsoft.com/library/1hb809fy.aspx


本贴子以“现状”提供且没有任何担保,同时也没有授予任何权利

posted @ 2005-02-07 16:53 Roger Wo 阅读(978) | 评论 (1)编辑

2005年2月4日 #

关于AD编程的一些资料

     摘要: 有人问我怎样在.NET下操作AD对象,找了些资料和Sample,留作备用。  阅读全文

posted @ 2005-02-04 16:24 Roger Wo 阅读(1283) | 评论 (0)编辑

2004年12月11日 #

Microsoft发布Member Management 组件 for ASP.NET v1.1

Member Management可以非常容易地创建和管理用户、对 Web 应用程序中的页面进行密码保护。尽管是ASP.NET 2.0新增的功能,现在我们也可以在ASP.NET 1.1下使用Member Management Component了!不用再自己去写代码实现user check, role based authentication了,在DotNetNukeCommunity Server中,都已经用到了这个组件。

下载地址:
http://www.asp.net/MemberRoles/WSHA-MemberRoles.msi

安装之后就可以在ASP .NET 1.1上使用System.Web.Security NamespaceSystem.Web.Profile Namespace了。

This is also a non Microsoft supported component.

posted @ 2004-12-11 23:06 Roger Wo 阅读(1919) | 评论 (6)编辑

2004年11月20日 #

我的hotmail信箱容量变成2G了!

今天无意中发现的,庆祝一下!!

posted @ 2004-11-20 00:04 Roger Wo 阅读(797) | 评论 (2)编辑

2004年11月11日 #

好消息: Gmail 推出pop3服务了

终于可以用outlook来收取Gmail邮件了!
pop3: pop.gmail.com
smtp:smtp.gmail.com
一定要使用ssl链接,不过暂时还不支持IMAP协议。

详细设置请参照:
http://gmail.google.com/support/bin/answer.py?answer=10350&rand=0.6764270708572596


 

posted @ 2004-11-11 16:19 Roger Wo 阅读(3671) | 评论 (11)编辑

msdn mag Dec 2004 (preview)

posted @ 2004-11-11 09:10 Roger Wo 阅读(540) | 评论 (0)编辑

2004年11月9日 #

在client端通过java script调用Web Service

     摘要: 以下代码实现了在客户端用java script调用Web Service,通过对Web Service:TimeService中GetTime()方法的调用,在客户端显示服务器当前时间,并且以1秒为间隔自动刷新。TimeService: GetTime() //Return time on server     ... 阅读全文

posted @ 2004-11-09 13:47 Roger Wo 阅读(5676) | 评论 (4)编辑

2004年11月3日 #

DataGrid绑定对象为数组时怎样确定DataFileld

昨天有人问了我这样一个问题:
指定DataGrid的DataSource为一个简单的一维数组,并且需要通过BoundColumn来显示,那么这个BoundColumn的DataFileld值应该是什么?注意:仅仅是一个System.Array数组,而不是ArrayList。

答案是 "!"。

这样的数组确实是没有data field name的,所以.net会把它当作"!"来看待。当然,通常情况下直接把一个数组作为数据源绑定到DataGrid,这种情况在实际使用中倒也不多见。

posted @ 2004-11-03 10:32 Roger Wo 阅读(2334) | 评论 (4)编辑

2004年11月2日 #

为asp.net程序添加自定义配置区域

我们通常把诸如sql的connection string之类的配置信息保存在web.config的AppSettings部分,以方便程序的分发,并且可以通过以下方法在程序中获得:
string sqlStr = System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"];

对于结构比较复杂的自定义配置,可以通过实现IConfigurationSectionHandler接口来实现这种机制。首先,创建MySettings类,该类仅包含了我需要的一些自定义配置的定义:

using System;

namespace myconfig
{
    
public class MySettings
    
{
        
public string SomeSetting; //自定义一个string类型的配置信息

        
public MySettings()
        
{
        }

    }

}

接下来关键的一步就是创建用于处理刚才定义好了的MySettings这类配置的MyConfigHandler,需要实现IConfigurationSectionHandler接口,IConfigurationSectionHandler只有一个方法:

object Create(
  
object parent,
   object configContext,
   XmlNode section
 );

因为web.config文件是一个标准的xml文件,所以可以非常简单得读出其中XmlNode的值:

using System;
using System.Configuration;
using System.Xml;

namespace myconfig
{
    
public class MyConfigHandler: IConfigurationSectionHandler
    
{
        
public MyConfigHandler()
        
{
        }

    
        
public object Create(object parent, object input, XmlNode node) 
        
{
            MySettings myset 
= new MySettings();
            
foreach (XmlNode n in node.ChildNodes) 
            
{
                
switch (n.Name)
                
{
                    
case("SomeSetting"): //从web.config读取SomeSetting的值
                        myset.SomeSetting = n.InnerText; 
                        
break;
                    
default:
                        
break;
                }

            }


            
return myset;

        }


    }

}

至此所有的自定义配置类和Handler都已经创建好了,最后只要告诉web.config用MyConfigHandler来处理MySettings就可以了,需要在web.config添加下列内容:

    <configSections>
        
<section name="MySettings" type="myconfig.MyConfigHandler,myconfig"></section>
    
</configSections>
    
    
<MySettings>
        
<SomeSetting>This is a customer configuration setting.</SomeSetting>
    
</MySettings>

其中<configSecions>告诉web.config调用MyConfigHandler来处理MySettings,<MySettings>中保存的就是自定义的配置内容,例如在某个web page中执行如下代码:

        private void Page_Load(object sender, System.EventArgs e)
        
{
            
// Put user code to initialize the page here
            MySettings myset;
            myset 
= System.Configuration.ConfigurationSettings.GetConfig("MySettings"as MySettings;

            Response.Write(myset.SomeSetting);
        }

 

得到的结果将会是在客户端显示This is a customer configuration setting。其实还有另一种更简单的方法,就是利用NameValueFileSectionHandler,但是在添加配置信息时需要像在AppSettings中那样用<add name="" value=""></add>来添加键值,对于自定义配置来说意义不大,具体可以参考msdn中相关的文章。


Justin同学总是push我要多发些技术贴,否则就有点对不起他推荐我到这里来了,过两天有空的话就再写些关于自定义httpHandlers和httpModules的文章吧,hoho,被人push真不爽。

posted @ 2004-11-02 21:41 Roger Wo 阅读(1795) | 评论 (6)编辑

2004年11月1日 #

first day in microsoft

今天是我在微软gtec上班的第一天,早早就来到了美罗大厦,这时虽然离九点还有一刻钟,本以为电梯会比较空的,没想到第一天就见识到了传说中美罗早上电梯排大队的情况,一共6部电梯分高低两个区,尽管每部电梯里的人数都达到了最优装载,外面还依旧排着长队,想想原先在外滩中心有十几部电梯同时运行都回拥挤,碰到这种情况也就不足为奇了,看来以后还得赶早。

原本以为一天会在无聊地setup机器中度过,没想到却被告知我的帐号和信箱还要过两天才能开通,无奈在和周围的同事简单招呼之后就只能坐在自己的位子上无所适从,还好马上被manager叫到office里去签些保密协议,vendor协议之类的文件,manager是个很nice的人,据说是很体恤下属的:-),她给我这一个周的任务就是看一些技术资料,把机器工作环境setup起来,看来我还得过一段时间才开始做case,在这之前还有好多东西要学呢。

中午和两个刚认识的同事到楼下的永和去吃饭,才知道原先19楼的食堂现在已经没有了,大家现在都改去外面吃午饭了,我发现好多人都是直接叫的外卖,大概是为了节省时间吧。在楼下碰到2个之前认识的熟人,打了声招呼,可惜他们都和我不在一个楼层。吃完中饭回到公司已经快1点了,继续看书吧,空空的桌子上除了那台熟悉的电话机外也没什么别的东西,中间抽空到24楼办了张key card。一天的时间就这样一点点得过去了,尽管已经临近下班,周围的同事们似乎仍旧在忙于手头的case,我的mentor也还要过几天才定下来,看来这几天我就安心看书学习吧。

posted @ 2004-11-01 20:08 Roger Wo 阅读(371) | 评论 (3)编辑

2004年10月31日 #

new blog, new life

终于决定在这里安营扎寨了,感谢dudu老大和Justin同学的大力推荐。无奈于自己的服务器老是罢工,再加上要跑一个sps,对于一台512M的p4实在是够呛了,当然,搬家的主要原因还是这里有这么多热爱.net的technical guy们,在这里先跟个位新邻居问声好:-)

posted @ 2004-10-31 22:38 Roger Wo 阅读(547) | 评论 (10)编辑