宝玉的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

广告

网易的博客,技术不错,缺少创新

今天看到网易的博客(http://blog.163.com)发布了,网易的技术确实不错,用起来感觉体验很好,就是用起来很有点似曾相识,主要功能是Spaces的翻版,相册很多借鉴了Flickr。

posted on 2006-09-19 23:55:00 by 宝玉  评论(10) 阅读(8142)

模版页中引用文件路径的问题

模版页中难免要引用CSS、脚本、图片等,这些文件的路径如果简单的使用相对路径,那么如果引用模版的目录一发生变化,这些路径就会出错;如果使用绝对路径,又不够灵活,如果应用程序目录发生变化,可能会导致要大量修改。asp.net支持一种相对于应用程序的路径,以波浪线开头的,形如"~/",使用它即可解决,例如:
<link rel="stylesheet" media="screen" type="text/css" href="<%=ResolveClientUrl("~/css/global.css") %>" />

当然如果你觉得每个路径都要写成动态的不爽,而又正好有页面基类的话,倒是可以换一种方式:

所有的路径直接书写为相对于应用程序目录的路径,形如:
<link rel="stylesheet" media="screen" type="text/css" href="~/css/global.css" />
当然默认HTML是不支持的这样的路径方式的,这时候就要借助PageBase了,代码如下(好像是从DNN的代码里面抠出来的):

 

    public abstract class PageBase : Page
    {
        protected override void Render(HtmlTextWriter writer)
        {
            StringWriter stringWriter = new StringWriter();
            HtmlTextWriter htmlWriter = new HtmlTextWriter(stringWriter);
            base.Render(htmlWriter);
            string html = stringWriter.ToString();
            #region 转换相对路径
            MatchCollection collection = Regex.Matches(html, "<(a|link|img|script|input|form).[^>]*(href|src|action)=(\\\"|'|)(.[^\\\"']*)(\\\"|'|)[^>]*>", RegexOptions.IgnoreCase);
            foreach (Match match in collection)
            {
                if (match.Groups[match.Groups.Count - 2].Value.IndexOf("~") != -1)
                {
                    string url = this.Page.ResolveUrl(match.Groups[match.Groups.Count - 2].Value);
                    html = html.Replace(match.Groups[match.Groups.Count - 2].Value, url);
                }
            }
            #endregion
            writer.Write(html);
        }
    }

posted on 2006-09-19 23:43:00 by 宝玉  评论(21) 阅读(11952)

《最优化ASP.NET——面向对象开发实践》

这是我和两位师弟(NickLedsonSheva)一起翻译的一本Asp.Net书 ,感谢搏客堂的关心为此书作了序《序言 - 最优化ASP.NET: 面向对象开发》,即将公开发售。此书尤其适合那些从asp转到asp.net的程序员,或者还没有面向对象概念的asp.net程序员。

附:

宣传页:http://www.huachu.com.cn/2006/aspnet.htm 

链接地址:
http://www.china-pub.com/computers/common/info.asp?id=31564
http://www.dearbook.com/book/110871

posted on 2006-09-19 00:14:00 by 宝玉  评论(13) 阅读(6386)

Asp.Net最佳实践BOF

时间:9月21日 14:30 ~ 15:30

地点:会场5楼 Track Cabana - BOF 5

主题:asp.net开发最佳实践

讲师:蒋林春/黄磊

 

蒋林春是我现在移动飞信项目组的同事,我将协助主持本次BOF,希望借此机会和大家一起探讨一下设计开发高质量、可重用与易维护的Web应用的方法。

posted on 2006-09-18 23:51:00 by 宝玉  评论(7) 阅读(6024)

让DotText095支持LiveWriter直接上传照片

首先请看这两篇Blog

http://weblogs.asp.net/lkempe/archive/2006/08/27/C_2300_-implementation-of-newMediaObject-for-the-MetaWeblog-API.aspx

http://www.cnblogs.com/Luna/archive/2006/09/08/498799.html

基本原理已经讲明白了,因为例子中代码没有和DotText的相册整合,所以需要自己动手做一点改动,使LiveWriter的照片能直接上传到DotText的相册中,方便管理,也没有多少技术含量,直接贴上代码,省得大家做重复劳动。

MetaWeblogAPI.cs 中增加:

----------------------------------------------------

public struct MediaObjectUrl
{
public string url;
}

public struct MediaObject
{
public string name;
public string type;
public byte[] bits;
}

?

public interface IMetaWeblog
{

//新增接口

[XmlRpcMethod("metaWeblog.newMediaObject",
Description="Add a media object to a post using the "
+ "metaWeblog API. Returns media url as a string.")]
MediaObjectUrl newMediaObject(
string blogid,
string username,
string password,
MediaObject mediaObject);

}

----------------------------------------------------

MetaWeblog.cs中新增

----------------------------------------------------

///


/// Post a media object.
///

/// The blogid.
/// The username.
/// The password.
/// The media object.
/// MediaObjectUrl defining the url of the media
public MediaObjectUrl newMediaObject(string blogid, string username,
string password, MediaObject mediaObject)
{

BlogConfig config = Config.CurrentBlog();
if(ValidateUser(username,password,config.AllowServiceAccess))
{
mediaObject.name = mediaObject.name.Replace("/", "_");
int categoryId = GetMetaWeblogImageCategoryId();

Dottext.Framework.Components.Image image = new Dottext.Framework.Components.Image();
image.CategoryID = categoryId;
image.Title = mediaObject.name;
image.IsActive = true;
image.File = mediaObject.name;
image.LocalFilePath = string.Format("{0}\\{1}\\",config.ImageDirectory,categoryId);
int imageID = Images.InsertImage(image, mediaObject.bits);

string imagePath = config.ImagePath;
MediaObjectUrl mediaObjectUrl = new MediaObjectUrl();
mediaObjectUrl.url = String.Format("{0}{1}", string.Format("{0}{1}/", imagePath,categoryId),
image.OriginalFile);
return mediaObjectUrl;
}
throw new XmlRpcFaultException(0,"User does not exist");
}

private int GetMetaWeblogImageCategoryId()
{
string name = "Meta Weblog Images"
LinkCategoryCollection categories = Links.GetCategories(CategoryType.ImageCollection, false);
foreach(LinkCategory lc in categories)
{
if (lc.Title == name)
{
return lc.CategoryID;
}
}

LinkCategory category = new LinkCategory();
category.CategoryType = CategoryType.ImageCollection;
category.Title = name;
category.IsActive = true;
category.Description = "MetaWeblogAIP专用,请勿删除和修改此分类!"

return Links.CreateLinkCategory(category);
}

posted on 2006-09-17 13:45:00 by 宝玉  评论(15) 阅读(6501)

如何配置博客堂的LiveWriter(支持直接上传图片)

1、在菜单中选择“Weblog”,然后选择“Another Weblog Service”。
2、在Weblog Homepage URL中输入你的Blog主页地址。
3、输入用户名与密码。
4、在“Type of weblog that you are using”中选择“Custom(Metaweblog API)”。
5、“Remote posting URL for your weblog”中输入“http://blog.joycode.com/{username}/services/metablogapi.aspx”。

推荐几个不错的LiveWriter插件:http://www.codeplex.com/Release/ProjectReleases.aspx?ProjectName=WLWPlugins

使用LiveWriter上传图片,会直接在您的相册中创建固定分类,以后所有LiveWriter中的图片都会上传至该分类!该功能源码见《让DotText095支持LiveWriter直接上传照片

弄张小宝玉的照片试验一下:)

posted on 2006-09-17 13:27:00 by 宝玉  评论(10) 阅读(5830)

用百度搜索"asp.net",三条结果,全是广告

希望百度能改进一下!

?

posted on 2006-09-13 10:51:00 by 宝玉  评论(200) 阅读(9036)

我的asp.net程序当前占用了多少内存?

如果您想在页面中显示出来当前asp.net程序占用了多少内存,那么可以使用:

            double memoryUsage = (((double)System.Diagnostics.Process.GetCurrentProcess().WorkingSet64) / 1024) / 1024;

来计算,单位是MB。

posted on 2006-09-03 22:03:00 by 宝玉  评论(14) 阅读(7241)

Powered by: Joycode.MVC引擎 0.5.2.0