blogjava's web log

blogjava's web log
...

以后不说话,只贴代码和看到的链接,当个备忘录吧.另外,我已近一年没有接触java。所以,贴的代码和链接大多是关于asp.net的。BlogJava - 专注于Java技术,看到这个标题我总很惭愧,专注于Java技术,我在这里贴c#代码..虽然博客园我也有申请博客,但和blogjava呆的时间相对比较长,也算有点感情,我也懒的搬,以后发布随笔的时候尽量不发布到blogjava随笔分类上。希望不会影响到blogjava的质量.

-----

我发布随笔是用windows live writer,所以一下发个10几篇上来。同志们不要觉得我很疯狂。很多随笔都是我以前的笔记和摘抄.

posted @ 2007-05-12 22:23 record java and net 阅读(384) | 评论 (0)编辑 收藏

<form id="form1" runat="server">
<div>
<asp:GridView ID="gvCategories" runat="server" AutoGenerateColumns="false">
<Columns>
<asp:TemplateField>
     <HeaderTemplate>Select All
           <input type="checkbox" id="chkAll" name="chkAll" onclick="Check(this,'^gvCategories')"/>
       </HeaderTemplate>
<ItemTemplate>
<asp:CheckBox ID="chkSelect" runat="server" />
</ItemTemplate>
</asp:TemplateField>
 
<asp:TemplateField HeaderText="Category Name">
<ItemTemplate>
<asp:Literal ID="litCategoryName" runat="server" Text = '<%# Eval("CategoryName") %>' />
</ItemTemplate>
 
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:GridView ID="gvProducts" runat="server" AutoGenerateColumns="false">
<Columns>
<asp:TemplateField>
<HeaderTemplate>
Select All
<input type="checkbox" id="chkAll" name="chkAll" onclick="Check(this,'^gvProducts')"/>
</HeaderTemplate>
<ItemTemplate>
<asp:CheckBox ID="chkSelect" runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Product Name">
<ItemTemplate>
<asp:Literal ID="litProductName" runat="server" Text = '<%# Eval("ProductName") %>' />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
 
<script language="javascript" type="text/javascript">
//var pattern = '^gvCategories';
function Check(parentChk, pattern)
{
var elements = document.getElementsByTagName("INPUT");
for(i=0; i<elements.length;i++)
{
  if(parentChk.checked == true)
{
if( IsCheckBox(elements[i]) && IsMatch(elements[i].id, pattern))
{
elements[i].checked = true;
}
}
else
{
if( IsCheckBox(elements[i]) && IsMatch(elements[i].id, pattern))
{
elements[i].checked = false;
}
}
}
}
 
function IsMatch(id, pattern)
{
var regularExpression = new RegExp(pattern);
return id.match(regularExpression);
}
function IsCheckBox(chk)
{
return (chk.type == 'checkbox');
}
</script>
</form>
</body>
</html>
posted @ 2007-05-12 22:03 record java and net 阅读(3425) | 评论 (1)编辑 收藏

当我正要找的时候,竟然就让我碰到了下面这段代码。运气不错

/// <summary>
/// Checks a connection string for validity
/// </summary>
/// <param name="cn">SQL Connection string to validate</param>
/// <returns>True if connection is valid.</returns>
/// <history>
///     [Tim Hibbard]   12/03/2006  Created
/// </history>
public static bool IsValidSQLConnectionString(string cn)
{
    bool RV = true;
    try
    {
        if (!cn.Contains("Data Source"))
        {
            throw new MissingMemberException("Missing Data Source");
        }
        if (!cn.Contains("Initial Catalog"))
        {
            throw new MissingMemberException("Missing Initial Catalog");
        }
        if (!cn.Contains("User ID"))
        {
            throw new MissingMemberException("Missing User ID");
        }
        if (!cn.Contains("Password"))
        {
            throw new MissingMemberException("Missing Password");
        }
        string[] contents = cn.Split(char.Parse(";"));
        if (!contents[0].StartsWith("Data Source"))
        {
            throw new MissingMemberException("Missing Data Source");
        }
        if (!contents[1].StartsWith("Initial Catalog"))
        {
            throw new MissingMemberException("Missing Initial Catalog");
        }
        if (!contents[2].StartsWith("User ID"))
        {
            throw new MissingMemberException("Missing User ID");
        }
        if (!contents[3].StartsWith("Password"))
        {
            throw new MissingMemberException("Missing Password");
        }
    }
    catch (Exception)
    {
        RV = false;
    }
    return RV;
}
Update to SQL connection string validation code
posted @ 2007-05-12 21:37 record java and net 阅读(393) | 评论 (0)编辑 收藏

构造多个查询。效果不错。注意Nhibernate CreateMultiQuery()这个方法
public void MultiQueryTest(int var)
{
   ISession session = null;
   session = Class1.GetFactory().OpenSession();
   IList result = session.CreateMultiQuery().Add("from Archives where id>:id")
      .Add("select count(*) from Archives a where id>:id").SetInt32("id", var).List();
   //获得第一个查询结果
   IList archives = (IList)result[0];
   long count = (long)((IList)result[1])[0];

   //当然也可以session.CreateQuery 构造查询
    //IList result = session.CreateMultiQuery()
     //    .Add(session.CreateQuery("from Archives where id>:id").SetFirstResult(5).SetMaxResults(10))
    //    .Add(session.CreateQuery("select count(*) from Archives a where id>:id"))
    //    .SetCacheable(true).SetInt32("id", var).List();
    // IList archives = (IList)result[0];
   //long count = (long)((IList)result[1])[0];

 }
 
//helper 
public class Class1
    {
        private static ISessionFactory factory;
        private static string _mappingAssembly;
 
        static Class1()
        {
 
            _mappingAssembly = ConfigurationManager.AppSettings["EntityAssemblyName"];
            NHibernate.Cfg.Configuration cfg = new NHibernate.Cfg.Configuration();
            foreach (string assembly in _mappingAssembly.Split(','))
            {
                try
                {
                    cfg.AddAssembly(assembly);
                }
                catch (MappingException me)
                {
                    throw new MappingException("Assembley Could Not Be Loaded: " + assembly, me);
                }
            }
 
            factory = cfg.BuildSessionFactory();
        }
 
        public static ISessionFactory GetFactory()
        {
            return factory;
        }
     }
更多精彩关注 http://www.ayende.com/
posted @ 2007-05-12 21:18 record java and net 阅读(803) | 评论 (0)编辑 收藏

       Download : http://www.asp.net/downloads/futures/

    Quickstart : http://quickstarts.asp.net/futures/

     

  • ASP.NET Ajax futures
  • Silverlight Controls for ASP.NET
  • Dynamic Data Controls for ASP.NET
  • ASP.NET Application Services
  • Dynamic Languages Support in ASP.NET
posted @ 2007-05-12 20:52 record java and net 阅读(533) | 评论 (0)编辑 收藏
仅列出标题
共31页: 上一页 1 2 3 4 5 6 7 8 9 下一页 Last 

导航

常用链接

留言簿(44)

新闻档案

2.动态语言

3.工具箱

9.文档教程

友情链接

搜索

最新评论