My Ajax call replace a dropdown box,  then call
$('select').each(function () {
              $(this).selectBox();
            });

to update the jquery selectBox look and feel again.

but it caused the "setting is undefined: settings.menuTransition" error,

to fixed that need add

            $('select').each(function () {
                $(this).selectBox('destroy');
              
            });
Before the Ajax Call, so the next time you Initial it .the dropdown will be function..

 
Categories: JQuery

September 16, 2011
@ 12:44 AM
check the JQuery Ajax:
$.ajax({
type: "POST",
url: this.url,
data: form_data,
beforeSend: function() {
$('#ajaxDetails').addClass('progress');
},
error: function() {
$('#status').text('Update failed—try again.').slideDown('slow');
},
success: function() {
$('#status').text('Update successful!');
},
complete: function() {
$('#ajaxDetails').removeClass('progress');
setTimeout(function() {
$('#status').slideUp('slow');
}, 3000);
}
});

to get the from data:
var form_data = $("form").serialize();
var form_data_array = $("form").serializeArray();
a simple example:
$(document).ready(function() {
$('#submit').click(function () {
var name = $('.uname').val();
var data = 'uname=' + name;
$.ajax({
type:"GET",
url:"welcome.php",
data: data,
success: function (html) {
$('#message').html(html);
}
});
return false;
});
});


and MVC3 Ajax
@using (Ajax.BeginForm(       
"ActionName",
"ControllerName",
new AjaxOptions {
 UpdateTargetId = "modal-dialog",
OnFailure="searchFailed",
OnBegin = "Dialog.Updating()",
OnSuccess = "Dialog.Update({title:'Select Friends'})"
})) {
… <input type="submit" value="Next" />
}





 
Categories: JQuery | MVC

September 10, 2011
@ 01:05 AM
I created a new MVC project, and test the remote validation in the about page.

1)Controller Home:
               public ActionResult ValidateTestName(string testName)
        {
            return Json(!testName.Equals("test"),
                        JsonRequestBehavior.AllowGet);
        }
2)Model:
using System.ComponentModel.DataAnnotations;
using System.Web.Mvc;

namespace MvcApplication1.Models
{
    public class AboutModel
    {
        [Required]
        [Remote("ValidateTestName", "Home", ErrorMessage = "this Name already be used.")]
        public string TestName { get; set; }

        [Required]
        [Range(20, 44)]
        public int Age { get; set; }
    
    }
}  
3)View:
In _Layout.cshtml:
 

    
    
In About.cshtml

@model MvcApplication1.Models.AboutModel
@{
    ViewBag.Title = "About Us";
}

About

Put content here. @using (Html.BeginForm()) { @Html.EditorForModel(); "submit" value="Submit" /> }


It is working perfect under FireFox 6:



but not working in my IE9 :(...
I have downloaded Jquery.Validation 1.8.1 try to fix this issue, but looks still unlucky.
(Jquery.Validation site : http://bassistance.de/jquery-plugins/jquery-plugin-validation/)


but this post in stack overflow said it tested in
Chrome 10.0, IE9 and FireFox 4.0
 
Categories: Asp.net | MVC

August 16, 2011
@ 12:35 PM
http://fsymbols.com/computer/trademark/#windows

hold alt and input 0153 you will got ™
0174 you will got ®

to put/replace them in string:
str.Replace("&#174;","\u00AE").Replace("&#174", "\u00AE").
                    Replace("&#0153;", "\u2122")


some time you need use <sup>&reg;</sup> in html


 
Categories: WebDesign

August 15, 2011
@ 08:47 PM
this file is made last year before I changed job.

Favorite Projects.docx (17.61 KB)
 
Categories: ProjectManagement

http://www.cnblogs.com/lori/archive/2011/07/18/2109817.html

前提:数据底层,使用的是MVC架构,对于数据表中的状态及相关字段,采用了枚举型进行对应

 

1 序列中不包含任何元素
  解决:将Single()改为DefaultOrSingle()

2 序列包含一个以上的元素
  解决:很多情况都是原始数据的问题

3 不能在已使用的实体上添加新实体
4 Duplicate key is already ,
  3,4的解决为:用  base._db.ExecuteCommand()进行SQL语句的重写,

不要用LINQ自带的insert,就不会出现错误了

5  未将对象引用设置到对象的实例。 值不能为空。参数名: source。
   解决:  this.iProduct_ProductFilesRepository.Insert(_entity.Product_ProductFile.Cast<Entity.IDataEntity> ().ToList());,当遇到将list实体类型换为接口list规范时,应该用.Cast<接口类型>().ToList()

6 查询参数不能为“System.Object”类型。
解决:这是因为在LINQ的ExecuteCommand不理解空值,当我们传递的参数为 null 时,就会出现这个问题,解决方法是,在为实体加string.empty这个空值属性

7  Incorrect syntax near '@p0'.
解决:查看我们的SQL代码,被编译成了什么,可能是多个括号之类的。如:delete from users where (userid={0},这很明显是不对的,哈哈

8 不支持SQL的转化
   解决1,看看是否用了枚举类型,如果用了,应该先把IQueryable进行ToList,得到真正的数据后才能进行判断
   解决2,请看你的原始数据,很有可以是数据问题
   解决3,请看程序代码的关联表查询,很可能是它没有找出数据的问题

9  未将对象引用设置到对象的实例。
解决:查看数据库向数据实体赋值时,枚举类型的字段是否为null了,如果为null,就会出错

10    查询包含对不同数据上下文上所定义项的引用。
解决:查看底层工厂建立是否返回datacontext有问题,是否为空了。

11    枚举在LINQ中引发的异常:不支持SQL转换
    当枚举使用字符名称,没有数据,然它的数值存储在数据表中时,我们在返回数据时,必须在ToList()才行,否则就会出现这种问题
    例如:
     /// <summary>
     /// 以下是一个积分类型的枚举,一种类型对应数据表中同样类型的一个数值
     /// </summary>
   public enum PrestigeTypeCode
    {
           IAsk_Question,
            IAsk_Answer,
  }

  //表据表如下:
ID    描述        数值    枚举名称
1   提问           1    IAsk_Question
2   回答           1    IAsk_Answer

结论:当我们通过枚举去从数据库(SQLSERVer里)取数值时,必须要把结果集ToList()才行,如代码:
int value = new PrestigeTypesRepository().GetPrestigeTypes().ToList().Where(item => item.PrestigeTypeCode == prestigeTypeCode).Single().Amount;
如果,枚举的值,在枚举元素里读上,就不用去tolist()了

12 不能将 Null 值赋给类型为 System.Int32 (不可为 null 的值类型)的成员
解决:应该是数据的问题,Int类型的SQL表中出来了NULL值,或者是由于枚举类型转换失败的原因


 
Categories: MVC

1. if net.tcp not enable on the server, you will see "The protocol 'net.tcp' is not supported." error message:



2. You need install and turn on the feature in Control panel\Programs and features:



3. then enable the protocols of your service:



4. set up the binding port:



5. done. it should be work, if not work, check those step again and the binding address in you web.config file.
I will post my service code and client code later.

 
Categories: WCF

ILmerge.exe download link from Microsoft.

info: http://research.microsoft.com/en-us/people/mbarnett/ILMerge.aspx

For example, the following command could be issued to combine one primary assembly and two secondary assemblies into a single merged DLL file:

ilmerge /out:Merged.dll Primary.dll Secondary1.dll Secondary2.dll

using wildcard:
ilmerge /wildcards /out:Merged.dll Primary.dll Secondary*.dll

log:
ilmerge /log:log.txt /out:Merged.dll Primary.dll Secondary1.dll Secondary2.dll


 
Categories: VS 2005 | VS 2008

from:(http://msdn.microsoft.com/en-us/library/ff647180.aspx)

Step 7: Create a Test Client Application

In this step, you create a Windows Forms application named Test Client to test the WCF service.

  1. Right-click your solution, click Add, and then click New Project.
  2. In the Add New Project dialog box, in the Templates section, select Windows Forms Application.
  3. In the Name field, type Test Client and then click OK to create a Windows Forms application.
  4. Right-click your client project and then click Add Service Reference.
  5. In the Add Service Reference dialog box, set the Service URI: to net.tcp://localhost:8523/WCFTestService and then click Go.
  6. Change the Service reference name: to WCFTestService and then click OK.

Step 8: Test the Client and WCF Service

In this step, you use the test client to ensure that the WCF service is running properly.

  1. In your client project, drag a button control onto your form.
  2. Double-click the button control to show the underlying code.
  3. In the code behind the button click, create an instance of the proxy, and call the DoWork() method of your WCF service.

    When you call the service, your current user security context will automatically be passed to your WCF service. The code should look as follows:

    private void button1_Click(object sender, EventArgs e)
    {
          WCFTestService.MyServiceClient myService = 
             new WCFTestService.MyServiceClient();
          MessageBox.Show(myService.DoWork("Hello World!"));
          myService.Close();
    }
    
    
  4. Right click the client project and then click Set as Startup Project.
  5. Run the client application by pressing F5 or CTRL+F5.

    When you click the button on the form, the message “Welcome Hello World!” should appear.

other ref: 

Host your WCF service with multiple host environment using multiple protocol


 
Categories: WCF