2013-0810

在做微信自定义菜单开发的时候报40016 invalid button size这个错误,莫名奇妙的,2-5个菜单数目也对啊,下边分享下C#版代码:

系列化类:

[Serializable]
public class Button
{
    public string name { get; set; }
}
[Serializable]
public class SubButton : Button
{
    public string type { get; set; }
    public string key { get; set; }
}
[Serializa 阅读全文>>
                
标签: 微信公众号接口 自定义菜单 40016 invalid button size 阅读:63796
2013-0805

我们在用mvc开发的时候新增数据提交表单时,ModelState.IsValid 提示The ID field is required.


我们先看下Model设计:


[Key]
[Editable(false,AllowInitialValue=true)]
[DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
public int ID { get; set; }


解说下,这里我们使用自动增长主键,切不允许编辑属性... 阅读全文>>

标签: MVC ModelState.IsValid 阅读:24477
2013-0801

tooltip要手动激活的好不好,还有那个popover,需要tooltip跟手动激活。

下面来说说那个tooltip的使用,先引用下官方的原话:

For performance reasons,  

the tooltip and popover data-apis are opt in,  

meaning you must initialize them yourself.




翻译过来就是:出于性能原因的考虑,tooltip和popover的data-apis是可... 阅读全文>>

标签: bootstrap tooltip 阅读:13642
2013-0730

MVC使用Ajax.BeginForm上传图片时HttpPostedFileBase file为null,Request.Files获取不到文件,问题分析是页面中存在jquery.unobtrusive-ajax.js文件,注释后能够获取到。改为Html.BeginForm实现如下:

@using (Html.BeginForm("UploadPhoto", "EditUserInfo", FormMethod.Post, new { enctype = "multipart/form-data" }))
{
选择图片:
<input type="file" name="uploa 阅读全文>>
                
标签: mvc Ajax.BeginForm HttpPostedFileBase 图片上传 文件上传 阅读:37380
2013-0730

百度接口相关说明:http://developer.baidu.com/map/ip-location-api.htm

返回是json格式,首先构建相关反系列化类:

#region AddressForQueryIPFromBaidu
[Serializable]
public class AddressForQueryIPFromBaidu
{
    public string Address { get; set; }
    public Content Content { get; set;  阅读全文>>
                
标签: C# 百度API 通过IP获取位置 IP获取坐标 阅读:22113
2013-0730

正则表达式用于字符串处理、表单验证等场合,实用高效。现将一些常用的表达式收集于此,以备不时之需。

匹配中文字符的正则表达式: [\u4e00-\u9fa5]
评注:匹配中文还真是个头疼的事,有了这个表达式就好办了

匹配双字节字符(包括汉字在内):[^\x00-\xff]
评注:可以用来计算字符串的长度(一个双字节字符长度计2,ASCII字符计1)

匹配空白行的正则表达式:\n\s*\r
评注:可... 阅读全文>>

标签: 常用正则表达式 Email正则表达式 URL正则表达式 电话正则表达式 身份证正则表达式 阅读:9583