宝玉的blog

专注于web开发技术
随笔 - 81, 评论 - 1563, 引用 - 157

导航

关于


目前致力于ChinaCommunityServer的开发。

msn: junminliu(at)msn.com

标签

每月存档

最新留言

  • re:发布一个爱心小软件——网页抓图
    <p>你好 我看了你的代码 不错啊,请问在asp.net C#中 没有了webbrowser 该怎么实现?</p> <p><a href="http...
    by weblogical(注册) on 2009/9/9 17:22:55
  • re:Openlab V2.0 Beta
    <p>宝玉你好: &nbsp; &nbsp; &nbsp; 我是个.net新手,最近看了openlab(openlab_V2.0_Beta)的源码。 ...
    by isforge(注册) on 2009/6/28 10:10:37
  • re:Openlab V2.0 Beta
    <p>宝玉你好: &nbsp; &nbsp; &nbsp; 我是个.net新手,最近看了openlab(openlab_V2.0_Beta)的源码。 ...
    by isforge(注册) on 2009/6/28 10:10:31
  • re:Openlab V2.0 Beta
    <p>宝玉你好: &nbsp; &nbsp; &nbsp; 我是个.net新手,最近看了openlab(openlab_V2.0_Beta)的源码。 ...
    by isforge(注册) on 2009/6/28 10:10:30
  • re:Openlab V2.0 Beta
    <p>宝玉你好: &nbsp; &nbsp; &nbsp; 我是个.net新手,最近看了openlab(openlab_V2.0_Beta)的源码。 ...
    by isforge(注册) on 2009/6/28 10:10:29
  • re:Openlab V2.0 Beta
    <p>宝玉你好: &nbsp; &nbsp; &nbsp; 我是个.net新手,最近看了openlab(openlab_V2.0_Beta)的源码。 ...
    by isforge(注册) on 2009/6/28 10:10:25
  • re:Openlab V2.0 Beta
    <p>宝玉你好: &nbsp; &nbsp; &nbsp; 我是个.net新手,最近看了openlab(openlab_V2.0_Beta)的源码。 ...
    by isforge(注册) on 2009/6/28 10:10:25
  • re:Openlab V2.0 Beta
    <p>宝玉你好: &nbsp; &nbsp; &nbsp; 我是个.net新手,最近看了openlab(openlab_V2.0_Beta)的源码。 ...
    by isforge(注册) on 2009/6/28 10:10:25
  • re:Openlab V2.0 Beta
    <p>宝玉你好: &nbsp; &nbsp; &nbsp; 我是个.net新手,最近看了openlab(openlab_V2.0_Beta)的源码。 ...
    by isforge(注册) on 2009/6/28 10:10:25
  • re:Silverlight中,防止ComboBox抢焦点
    <p>我是初学者,您已经写了一个 组件上传的功能 。。我在2008下测试通过,,,但是弄2005测试的时候 发现 progress.aspx.cs页面的</p> <p&...
    by jxh12345j(注册) on 2009/4/7 8:55:12
  • ufnnutdh - Google Search
    ufnnutdh - Google Search
    by (匿名) on 2008/10/27 17:44:45
  • veysaync - Google Search
    veysaync - Google Search
    by (匿名) on 2008/10/5 5:20:49
  • mzgmhgio - Google Search
    mzgmhgio - Google Search
    by (匿名) on 2008/9/22 23:34:49
  • rhmhnyma - Google Search
    rhmhnyma - Google Search
    by (匿名) on 2008/9/22 7:48:44
  • re: 发布一个爱心小软件——网页抓图
    Maxthon应该有这个功能
    by passos(匿名) on 2008/7/21 20:05:23

广告

CommunityServer实例分析——注册新用户(1)

对于类似于CommunityServer(简称CS)这样如此庞大的系统,很多朋友苦于无法入手,根据我对CS研究的一点经验,感觉从具体实例入手是最简单直接的。因此,我首先以注册新用户这个实例来向大家一步步揭开CS的神秘面纱。

1. 准备工作

本文以CCS(China Community Server,基于CS二次开发)为例,下载地址: http://www.communityserver.cn/builds,在压缩包里面有完整的源码和安装说明。

1.1 安装CCS
按照安装说明安装好CCS(如果安装过程中有问题可以到http://www.communityserver.cn上提问),本文以CCS安装在http://localhost/ccs为例。

1.2 打开源码
压缩包解压后,在src目录下就是所有的源码,先确认已经将http://localhost/ccs这个虚拟目录指向了src\web目录(如果您使用的是其它虚拟目录,请事先用文本编辑器修改src\Community Server.sln和src\web\CommunityServerWeb.csproj.webinfo其中的http://localhost/ccs为您的虚拟目录地址),不出意外,就可以用VS2003打开src\Community Server.sln了。

1.3. 页面效果
通过http://localhost/ccs/User/CreateUser.aspx可以访问注册页面,在注册页面,用户可以输入注册的基本信息,例如登录帐号、昵称、Email、密码等。在点击提交按钮后首先会对提交数据的合法性校验,例如:登录帐户是否为空、Email是否合法、两次输入密码是否一致等。数据合法性校验通过后,要检测是否已经存在相同的登录帐户、昵称和Email,最后就是将注册的数据提交到数据库,并提示用户已经注册成功。

3. 技术分析

3.1 分析页面源码
在VS2003中,在CommunityServerWeb项目中,展开User目录,打开CreateUser.aspx文件,切换到HTML视图,代码如下:
<%@ Page SmartNavigation="False" Language="C#"  enableViewState = "false" %>
<%@ Register TagPrefix="CS" Namespace="CommunityServer.Controls" Assembly="CommunityServer.Controls" %>
<%@ Register TagPrefix="CSD" Namespace="CommunityServer.Discussions.Controls" Assembly="CommunityServer.Discussions" %>
<%@ Import Namespace="CommunityServer.Galleries.Components" %>
<%@ Import Namespace="CommunityServer.Blogs.Components" %>
<%@ Import Namespace="CommunityServer.Components" %>

<CS:ContentContainer runat="server" id="MPContainer" ThemeMasterFile = "ForumMaster.ascx" >
    <CS:Content id="BodyContentRegion" runat="server">
  <CS:CreateUser runat="server" />
 </CS:Content>
</CS:ContentContainer>

3.2 自定义控件
没有我们熟悉的文本输入控件等,只有几个自定义控件标记,如果有Asp.Net的自定义控件基础知识,那么应该可以想到,这里用的是自定义控件。顺便温习一下Asp.Net自定义控件,首先,对于CS:ContentContainer标签,根据标签中的CS前缀,我们在页首的申明上找到TagPrefix="CS"的Register:
<%@ Register TagPrefix="CS" Namespace="CommunityServer.Controls" Assembly="CommunityServer.Controls" %>
根据其中的Namespace属性的值和Assembly属性的值我们可以知道,这里的CS:ContentContainer标签对应的源码就是在CommunityServer.Controls.dll中的CommunityServer.Controls.ContentContainer类。CommunityServer.Controls.dll实际上就是由解决方案中的CommunityServerControls项目生成的。

对于CS:ContentContainer和CS:Content是CS中用的模版控件,其实在Asp.Net2.0中已经内置了这种模版控件。CS在这里是用的一个第三方的模版控件:MetaBuilders.WebControls.MasterPages.dll,限于篇幅,在这里我就不做详细介绍。还是看看我们今天的主角:
<CS:CreateUser runat="server" />
根据上面的知识,我们可以直接从CommunityServerControls项目中找到CommunityServer.Controls.CreateUser类(一个小技巧就是在VS2003中切换到类视图,可以很方便找到该类对应的.cs文件),位于User目录下的CreateUser.cs文件。

3.3 TemplatedWebControl
打开源码(public class CreateUser : SecureTemplatedWebControl),可以知道CreateUser继承自SecureTemplatedWebControl类,那我们先看看SecureTemplatedWebControl类,SecureTemplatedWebControl类很简单,就是检查一下是不是需要使用Https连接,SecureTemplatedWebControl类又是继承自TemplatedWebControl类。其实在CS中,大部分类似于注册页面这样的控件都是继承自TemplatedWebControl,我们先来分析一下TemplatedWebControl的作用。


未完,待续……

 

posted on 2005-08-27 19:09:00 by 宝玉  评论(36) 阅读(11018)

招聘.Net开发人员(北京)

工作地点:北京

职责:
 
   电信新产品的开发工作,将根据经验和能力来安排具体的开发任务 

1. 客户端开发人员
     a). 熟悉.NET控件开发
     b). 熟悉.NET下的网络编程

2.后台服务开发人员
      a) .NET Remoting的相关开发工作
      b) Web Services的相关开发工作
      c) 熟悉ADO.NET
      d) 熟悉SQL Server开发

顺便介绍一下,我目前就在沈嵘这边工作,做电信相关产品,有不少高手在这边,例如博客堂就有几位。所开发的产品也很具有挑战性,前景很不错。

有意者请把简历发至:rongshen(a)microsoft.com (其中(a)替换为@)

posted on 2005-08-10 19:31:00 by 宝玉  评论(31) 阅读(6669)

Powered by: Joycode.MVC引擎 0.5.2.0