JS
function a(){ var guid = ""; for (var i = 1; i <= 32; i++){ var n = Math.floor(Math.random()*16.0).toString(16); guid += n; if((i==8)||(i==12)||(i==16)||(i==20)) guid += "-"; } alert(guid); }
.NET
string guid = System.Guid.NewGuid().ToString();//System.Guid.Empty.ToString(); System.Guid TaskId = new Guid(guid);//给数据库字段赋值时转换为guid类型