常用又容易忘记的JS小功能合集 本贴收集信息为自用,如果能帮到您,实属荣幸

本贴收集信息为自用,如果能帮到您,实属荣幸

jquery ajax 异步 async为flase,同步为true或者不增加此参数

 1  $.ajax({
 2                 type: "GET",
 3                 async: false,
 4                 url: "",
 5                 data: "",
 6                 contentType: "application/x-www-form-urlencoded; charset=utf-8",
 7                 success: function (result) {
 8                     
 9                 }
10             });
jquery ajax

 jquery判断checked的三种方法:
.attr('checked):   //看版本1.6+返回:”checked”或”undefined” ;1.5-返回:true或false
.prop('checked'): //16+:true/false
.is(':checked'):    //所有版本:true/false//别忘记冒号哦
jquery赋值checked的几种写法:
所有的jquery版本都可以这样赋值:
// $("#cb1").attr("checked","checked");
// $("#cb1").attr("checked",true);
jquery1.6+:prop的4种赋值:
// $("#cb1″).prop("checked",true);//很简单就不说了哦
// $("#cb1″).prop({checked:true}); //map键值对
// $("#cb1″).prop("checked",function(){
return true;//函数返回true或false
});
//记得还有这种哦:$("#cb1″).prop("checked","checked");

ASP.NET中Request.QueryString的乱码问题

   '引用System.Collections.Specialized和System.Text命名空间
   string stringValue;
   NameValueCollection gb2312Requests;
   gb2312Requests = HttpUtility.ParseQueryString(Request.Url.Query, Encoding.GetEncoding("GB2312"))
   Response.Write(gb2312Requests["string"]);  //'里面的string就是你提交的参数的Key

解决ASP.NET中的各种乱码问题

 XML反序列化

XmlSerializer xmlSearializer = new XmlSerializer(typeof(EntityXML.BookRQ));
EntityXML.BookRQ info = (EntityXML.BookRQ)xmlSearializer.Deserialize(s);

  DialogResult result = MessageBox.Show("确定要关闭软件吗?点击确定关闭,点击取消最小化", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
            if (result == DialogResult.OK)
            {
                Environment.Exit(0);
            }
            else
            {
                e.Cancel = true;
            }

  

  var filepath = Environment.SystemDirectory + @"..Microsoft.NETFramework";
            DirectoryInfo[] directories = new DirectoryInfo(filepath).GetDirectories("v?.?.*");
            bool flag = false;
            foreach (DirectoryInfo info in directories)
            {
                if (info.Name.Substring(1) == "3.5")
                {
                    flag = true;
                    break;
                }
            }
            if (!flag)
            {
                MessageBox.Show("您的电脑可能未安装Microsoft .NET Framework 3.5组件,请安装后再打开软件");
                Process.Start("http://www.microsoft.com/zh-cn/download/details.aspx?id=25150");
            }



            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            bool createdNew;//返回是否赋予了使用线程的互斥体初始所属权   
            System.Threading.Mutex instance = new System.Threading.Mutex(true, "MutexName", out createdNew); //同步基元变量   
            if (createdNew) //赋予了线程初始所属权,也就是首次使用互斥体   
            {
                Application.Run(new Form1());
                instance.ReleaseMutex();
            }
            else
            {
                MessageBox.Show("已经启动了一个程序,本软件不支持同一台电脑多开。", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Application.Exit();
            }

  

for (int i = 1; i < 20000; i++)
            {
                if (i % 1 == 0 && i % 2 == 1 && i % 3 == 0 && i % 4 == 1 && i % 5 == 4 && i % 6 == 3 && i % 7 == 0 && i % 8 == 1 && i % 9 == 0)
                {
                    MessageBox.Show("傻B结果=" + i);
                    break;
                }
            }
View Code
原文地址:https://www.cnblogs.com/ColorUltra/p/5491744.html