ASP.NET partial page upload without Updatepanel /With jQuery

后端 未结 4 1983
孤街浪徒
孤街浪徒 2021-01-07 13:33

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

4条回答
  •  花落未央
    2021-01-07 14:33

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

    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.

    The steps would go as follows:

    • 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.

    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.

    Here is a tutorial on how to use an IHttpHandler class.

提交回复
热议问题