易截截图软件、单文件、免安装、纯绿色、仅160KB

将jQuery应用于Asp.net Ajax时,应避免的3个错误

3 mistakes to avoid when using jQuery with ASP.NET AJAX
AJAX, ASP.NET, JavaScript, jQuery By Dave Ward on June 5th, 2008
Over the past few weeks, I think I have definitely embodied Jeff Atwood’s claim that we’re all amateurs, learning together. Despite my best efforts to thoroughly test before posting, a few problems slipped through in my recent posts about using jQuery to consume ASP.NET JSON serialized web services and using jQuery to call ASP.NET AJAX page methods.
On the bright side, your great feedback in both posts’ comments has reinforced the fact that some of the best content on my blog is the part that you write.
In this post, I’m going to detail three of the problems that were discovered as a result of those previous two posts:
An extra requirement when making a read-only request to IIS6+.
An oddity in Internet Explorer 7’s XmlHttpRequest class.
A common mistake when passing JSON parameters through jQuery.
Finally, I’ll suggest what I now believe to be a best practice usage, taking all of these issues into account.
Security requirements when POSTing to IIS
This error message was the most common problem that was reported:
Length Required
The underlying issue is that most installations of IIS6+ require a content-length be provided with all POST requests, even if there is no content (POST data).
The content-length for a request with no data should be 0, but jQuery doesn’t set that header automatically unless there is a data parameter. Since ASP.NET AJAX’s JSON serialized services require a POST request, this becomes a stumbling block for read-only requests.
The easiest way I’ve found to work around this is to use an empty JSON object as a parameter on read-only requests. For example, if you were calling a page method:
$.ajax({
type: "POST",
url: "PageMethod.aspx/PageMethodName",
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json"
});
This will c


相关文档:

ASP.NET中常用的三十三种代码

1. 打开新的窗口并传送参数:
传送参数:
response.write("<script>window.open('*.aspx?id="+this.DropDownList1.SelectIndex+"&id1="+...+"')</script>")
接收参数:
string a = Request.QueryString("id");
string b = Request.QueryString("id1");
2.为按钮添加对话框
Button1.Attributes.Add("o ......

asp.net 用继承方法实现页面判断session

在做ASP项目的时候,判断用户是否登陆常用的方法是在每个页面判断session是否存在,
无奈用java的时候过滤器就用的不熟。。。还是用继承吧。汗。。。
新建一个类
Csharp 代码
  using   System;  
  using   System.Web;  
  using   System.Web ......

asp.net 将中文翻译成拼音(VS2008)

3个文件
code 类文件
 using System;
using System.Text;
namespace ConcreteMIS.Common.Chinese
{
    /// <summary>
    /// 汉字拼音声母计算类
    /// Write by WangZhenlong at 2003/11/29
    /// </summary>
   ......

asp.net 获取本周、本月第一天和最后一天

 DateTime dt = DateTime.Now;
 //本月第一天时间   
DateTime dt_First = dt.AddDays(-(dt.Day) + 1);
 Label1.Text = dt_First.ToString("yyyy-MM-dd");
//将本月月数+1 
DateTime dt2 = dt.AddMonths(1);
//本月最后一天时间  
DateTime dt_Last = dt2.AddDays( ......

ASP.NET MVC中的验证

1.简单验证
在ASP.Net MVC中,验证是在Controller层,而错误呈现是在View层,Controller层是通过ModelState属性进行验证的,ModelState的状态是通过AddModelError()方法进行 添加的。
而在View层,是通过Html的辅助方法进行呈现的,这两个辅助方法分别是
Html.ValidationMessage()
Html.ValidationSummary()
Controller ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号