JQuery and ASP.NET Web Forms

I am creating an ASP.NET Web Form application where I am trying to use some nice features of jQuery and flashyness. The current part of the application that I have consists of two tabs of jQuery UI; search tab and results tab. When the user searches from the search page, the results tab will be selected and the results will be displayed on this tab. I need to get the results in gridview. Now this is where the problem begins to arise:

The easiest way to get the search results is to allow the search to click to perform the postback, where I can format the data source with the parameters from the input fields and let the datagrid take care of itself and bind the data and show the results. The fact is that it really doesn’t look like this wonderful (due to the whole post and back), and also starts to cause some problems using javascript / jQuery to take care of switching tabs and all this part, because postback reinitializes everything from by zovatelskogo jQuery interface (i.e. tabs jQuery UI). In short, postback makes it easy to link search input and get results, but makes the page and its behavior uncomfortable.

I was wondering if there is a standard way for this type of mixing jQuery / javascript / AJAX together in a web form to get the functionality of things like gridview, etc. I am wondering if there are good tutorials or even just a way to solve this problem.

I hope all of this made sense, and thank you all for your help.

0
source share
1 answer

I don't think this is standard, but here is the pattern I am using:

First of all, I use the Page Method for ASP.Net to connect to the server. In this case, it will be something like this:

PageMethods.Search(searchValue, onSearchComplete);

This calls the static method of the page on the page, for example:

public static void Search(string searchValue)
...

, gridview, , searchValue:

var searchControl = (SearchControl)new SearchControl().LoadControl("/controls/SearchControl.ascx");

searchControl.Search();

var stringBuilder = new StringBuilder();
using (var textWriter = new StringWriter(stringBuilder))
{
      var htmlWriter = new HtmlTextWriter(textWriter);

      searchControl.RenderControl(htmlWriter);
      return stringBuilder.ToString();
}

, (onSearchComplete). , , , div .

+1

Source: https://habr.com/ru/post/1791091/


All Articles