AJAX AutoCompleteextender without webservice - asp.net

As per my knowledge, we can use AJAX AutoCompleteextender via two ways either using 'Webservice' or by defining Service method in 'ASPX or ASCX' file.
I just wanted to know that is there any advantage in using webservice for AutoCompleteextender instead of writing Service method in ASPX or ASCX file?
|Thanks|

The webservice advantage is that it centralizes your lookups. You can have one webservice asmx page with several methods that all your other pages could use if needed. That would prevent having to have a separate Page Method on each document. Your lookups would be normalized over your entire site.

Related

How to redirect between different .aspx pages using angularjs?

I have two different aspx pages which operate using AngularJS. One page is to add a post and on clicking save, I want to redirect to the detailpage.aspx. Can this be done using AngularJS?
You could always use plain javascript to make a redirect to another server side resource:
window.location.href = '/detailspage.aspx';
By the way, is there any point of having multiple ASPX pages when using AngularJS? Usually a SPA application has a single entry point and multiple REST API endpoints that will be called by this SPA application using asynchronous requests.
$location.path(YOUR_URL); or $location.url(YOUR_URL);
$window.location.href = '/index.html';
I do use .aspx Pages as well, and use them as partials, to show their content using ajax. In my opinion you should consider going for a navigation/route provider...

call ajax and asp callbacks through proxy

I have two parts of my ASP site,
and i'm trying to view one site in the other, using proxy.
i'm doing it through IHttpHandler.
The site is looking good through the proxy, but i can't call AJAX, either use ASP callbacks (in my case a telerik grid).
any help would be appreciated.
Telerik controls (Like other MS AJAX based toolsets) utilize WebResources heavily. Make sure your proxy is transparent for them as well (e.g., either does not route them at all, or that they return succesfully, even though I do not know how one app could server another's webresource request).
Consider just framing those pages (e.g., in RadWindows, RadPanes inside a RadSplitter, simple iframes, whatever fits your design).
You can also try using the CDNs Telerik offers in addition to the MS AJAX CDN,so that less webresoures are being used.

What different customizations are possible by using HttpHandlers in an ASP.NET application?

Digging deeper into HttpHandlers I found they provide nice way to customize an ASP.NET application. I am new to ASP.NET and I want to know about different customizations that are possible using HttpHandlers. Lots of websites talk about how they are implemented but it would be nice to know some use cases beyond what ASP.NET already provides using HttpHandlers.
An ASPX page provides a base template (so to speak) for a form-based web page. By default, it outputs text/html and allows for easy adding of form elements and event handling for these elements.
In contrast, an HttpHandler is stripped to the bone. It is like a blank slate for HTTP requests. Therefore, an HttpHandler is good for many types of requests that do not necessarily require a web form. You could use an HttpHandler to output dynamic images, JSON, or many other MIME type results.
A couple examples:
1) You have a page which needs to make an AJAX call which will return a JSON response. An HttpHandler could be setup to handle this request and output the JSON.
2) You have a page which links to PDF documents that are stored as binary blobs in a database. An HttpHandler could be setup to handle this request and output the binary blob as a byte stream with a PDF MIME type for the content type.
Check this page for a good example and code of why you might want to customize them: http://dotnetslackers.com/articles/aspnet/Range-Specific-Requests-in-ASP-NET.aspx Essentially it can be used when you want to server certain files but not allow them to be accessible via a plain url (security).

How common usage are Page Methods in ASP.NET 4?

How common usage are Page Methods in ASP.NET 4?
I would like an example of how it's used (not a code sample).
I don't know about how common, but check out this example: http://aspalliance.com/1922_PageMethods_In_ASPNET_AJAX.all
Use page methods if you don't want to publicly expose a web service, and creating a web method that's specifically only to that page, IMHO. So for instance, I need web service features for one page only, that's when I create a page method. If I need something reusable in two pages, but don't want to publically expose it, I create a helper and the web method wraps the helper.
Otherwise, if you are looking to create a dynamic web site and share information, go with a traditional ASMX or WCF service.
HTH.
In your ASPX file you'll need this line.
<asp:ScriptManager ID="ScriptManager" runat="server" EnablePageMethods="true" />
In your code behind define a method marked as a WebMethod.
[WebMethod]
public static void MyMethod()
{
//code.....
Then to call that method in JavaScript.
PageMethods.SendForm(SuccessCallBack, FailureCallBack);
There are more advanced examples out there - just Google it.
I don't know about usage, but this is a very basic and clear example.

Dynamically loading content (ajax) other than using page methods

I'm working on a site at the moment that loads all of its browser popups by using page methods. This approach works but it's starting to get messy. I also view page methods as ways to perform small tasks, username availability comes to mind.
What other options are there besides page methods and the update panel?
You should look at the JQuery ajax functionality. http://api.jquery.com/category/ajax/
You can point the url of the AJAX request to an aspx page or an html page or pretty much any web resource that you like, as long as the request is handled on the server by some kind of HttpHandler. And as long as your callback handler is able to handle and display the returned resource
PageMethods sounding fine to me (which are essentially Webservices).
You could pull more data per request and use cache more. You could build a better JavaScript wrapper which satisfies the need for more tidiness.
You could choose another library: How to call a web service from jQuery

Resources