jQuery和放大器; ASP.Net资源和放大器;陷阱 [英] jQuery & ASP.Net Resources & Gotchas

查看:223
本文介绍了jQuery和放大器; ASP.Net资源和放大器;陷阱的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在与ASP.Net使用它有什么好的jQuery的资源以及一些陷阱?

What are some good jQuery Resources along with some gotchas when using it with ASP.Net?

推荐答案

有一点需要注意的是,如果你使用的WebMethods为Ajax,响应值将被退回包裹在一个名为D出于安全考虑的对象。你将不得不解开这个值,这通常不是问题,除非你正在使用的组件(如jqGrid的插件)即依靠jQuery的阿贾克斯。要解决这个问题,我只是改变了code在调用Ajax和插入位的code解开电网。我不打算派遣一些code到jQuery的剧组,看它是否可以接受在将来的版本。

One thing to note is that if you use WebMethods for Ajax, the response values will be returned wrapped in an object named 'd' for security reasons. You will have to unwrap that value, which is usually not a problem, unless you are using a component (such as the jqGrid plugin) that relies upon jquery ajax. To get around that, I just changed the code in the grid that called ajax and inserted a bit of code to unwrap. I do plan on sending in some code to the jquery crew to see if it can be accepted for future versions.

接下来的事情,正如提到的previously,是IDS。如果你有时间和倾角,其实我的子类的所有HTML控件,使参与NamingContainer可选,像这样的:

The next thing, as was mentioned previously, is the ids. If you have the time and inclination, I actually subclassed all of the HTML controls to make participating in the NamingContainer optional, like this:

protected override void RenderAttributes(HtmlTextWriter writer) {
	HtmlControlImpl.RenderAttributes(this, writer);
}

然后辅助对象(以prevent编写相同的code中的每个对象)看起来是这样的:

And then the helper object (to prevent writing the same code in each object) looks like this:

public static void RenderAttributes(IFormControl cntrl, HtmlTextWriter writer) {
	if (cntrl.ID != null) {
		cntrl.Attributes.Remove("id");
		cntrl.Attributes.Remove("name");
		writer.WriteAttribute("id", cntrl.RenderedId);
		writer.WriteAttribute("name", cntrl.RenderedName);
	}
	cntrl.Attributes.Render(writer);
	HtmlContainerControl containerCntrl = cntrl as HtmlContainerControl;
	if (containerCntrl == null)
		writer.Write(" /");
}

public static string GetRenderedId(IFormControl cntrl) {
	return cntrl.UseNamingContainer ? cntrl.ClientID : cntrl.ID;
}

public static string GetRenderedName(IFormControl cntrl) {
	return cntrl.UseNamingContainer ? cntrl.UniqueID : cntrl.ID;
}

这篇关于jQuery和放大器; ASP.Net资源和放大器;陷阱的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆