没有Updatepanel的ASP.NET部分页面上载/使用jQuery [英] ASP.NET partial page upload without Updatepanel /With jQuery

查看:64
本文介绍了没有Updatepanel的ASP.NET部分页面上载/使用jQuery的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个ASPX页面.在顶部,我显示5个类别(例如:笔,书,鞋,手机,镜子) 当我单击任何类别时,我想在标题下方显示该类别下的产品.我不想为此重新加载整个页面.我想保持我的页面的原样(页眉,页脚和侧面板会保留),当单击发生时,除了图像的中心位置(可能是要显示的DIV或表格)产品).最好的方法是什么?我不想去ASP.NET Ajax更新面板.我已经在我的项目中使用jQuery.请提出建议.谢谢!

I have an ASPX page .In the Top i am displaying 5 categories (Ex : Pen,Book,Shoe,Mobile,Mirror) When i click on any of the categories,I want to show the products under that category below the header. I dont want to reload the entire page for this.I want to maintain my page as it is (The header,footer and side panels would ) when a click happens except the center place of the image (may be a DIV or Table to show Product). Whats the best way to do this ?.I dont want to go for the ASP.NET Ajax update panel.I am already using jQuery in my project.So is there anyway to do this with jQuery ? Please advice .Thanks in advance

推荐答案

如Kirtan所述,最简单的答案以使用更新面板.

As Kirtan mentioned, the easiest answer is to use an Update Panel.

如果您不想走那条路,那么可以使用jQuery对IHttpHandler进行Ajax调用,该IHttpHandler返回您需要填充要更新的面板的数据.

If you don't want to go that route, then you can use jQuery to make Ajax calls to an IHttpHandler which returns the data you need to populate the panel you want to update.

步骤如下:

  • 使用jQuery调用".ashx" Ajax处理程序.
  • 让您的".ashx"文件以您选择的格式生成响应.可以是JSON或XML(如果您想让JavaScript解析响应并生成列表),或者可以将HTML内容本身添加到页面中.
  • jQuery将收到您的处理程序的响应,并使用适当的数据填充面板.
  • Use jQuery to call ".ashx" Ajax handler.
  • Have your ".ashx" file generate a response in your format of choice. This could be JSON or XML (if you want JavaScript to parse out the response and generate the list), or the HTML content itself to be added to the page.
  • jQuery will receive the response from your handler, and populate your panel with the appropriate data.

在线上有一些有关如何使用IHttpHander的教程.基本上,这是从ASP.NET的"Page"类派生的非常简单的接口.它的重量比Page类的重量轻得多,因此与UpdatePanel相比,您可以获得更好的性能,但是,与大多数性能提升技术一样,您的代码也稍微复杂一些.

There are a few tutorials online about how to use an IHttpHander. Basically it's a very simple interface that ASP.NET's "Page" class is derived from. It is much lighter weight than the Page class so you can get better performance than you would from an UpdatePanel, however, as with most performance boosting techniques, you have slightly more complex code.

这是有关如何使用IHttpHandler的教程课.

这篇关于没有Updatepanel的ASP.NET部分页面上载/使用jQuery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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