易截截图软件、单文件、免安装、纯绿色、仅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


相关文档:

解决datalist中单选按钮可以多选的问题(Asp.Net)

问题描述:
Asp.Net中datalist等web控件里面,放多个单选按钮的时候可以同时多选,可以采取以下放法。
问题解决:
最理想的解决之道,用javascript:
<script language="javascript" type="text/javascript">
function clickit() {
        var dom=document.all;
 & ......

ASP.NET AJAX调用WebService

如何在客户端直接调用WebService中的方法?
这里结合经验自己写一写
1.首先新建一个 ASP.NET AJAX-Enabled Web Site,这样系统为我们自动配置好了环境,这主要体现在Web.config这个文件上,如果已有网站不是ASP.NET AJAX-Enabled Web Site也可以对照修改下Web.config,也可以达到相同的效果。
2.新建一个web服务,WebSer ......

一个asp.net图片验证码程序

数字/字母混合很简单的,看着比较舒服,前台生成的aspx文件我就不贴出来了,默认的,我也未作修改。下面只贴出后台的cs代码。仅供参考。
public partial class CheckCode : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
this.CreateCheckCodeImage( ......

ASP.NET MVC中的验证

1.简单验证
在ASP.Net MVC中,验证是在Controller层,而错误呈现是在View层,Controller层是通过ModelState属性进行验证的,ModelState的状态是通过AddModelError()方法进行 添加的。
而在View层,是通过Html的辅助方法进行呈现的,这两个辅助方法分别是
Html.ValidationMessage()
Html.ValidationSummary()
Controller ......

JSON Serialization and Deserialization in ASP.Net


    
JSON Serialization and Deserialization in ASP.Net
 
I was looking around for a simple example which would just do an object serialization to a JSON format, and then deserializing back to the original object. I found few examples on MSDN, but did seem to be too long ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号