I am creating a SharePoint site through visual studio and I created a user control(ascx).I have written some methods on user control code behind file(axcs.cs). How can I call those methods through jquery ajax since methods on ascx.cs cannot be called by jquery ajax directly? Could you please help me?
Actually you cannot call a control's server methods from javascript (jquery/ajax).
However, depending on the logic that needs to be called you have options. For one, you can create a *.ashx handler that will handle requests from you javascript code and call server-side logic.
Related
Looking for some thoughts and feedback on making async requests from dust.js template helpers:
Dust.js can make async requests from template helpers, but is it actually a good idea to make use of them? Consider this scenario...
A particular page requires several api requests to be rendered. In the page's route controller, a single async api request gets the bulk of the data for the page and passes the data to the template to be rendered. In the template there are several reusable and standalone dust helpers (can be dropped in on any page) that make their own async requests in order to display their components.
In this situation, all the dust helpers have to wait until the request made from the controller finishes before their calls can be made (when template rendering begins).
It seems that ideally (excluding having one endpoint for all data on the page) all requests should occur in the route controller in order to avoid synchronous calls, otherwise the request chain would be 1) controller requests 2) dust helper requests 3) nested/dependent dust helper requests.
Cons:
route controller complexity by calling n services to build the view model
adding display components to new pages require changes to controller and template instead of just adding a template helper
Pros:
reduce/eliminate synchronous requests and increase performance
easier to understand the view model
What are your thoughts? Thanks!
If you consider to use your templates only server side I would move everything into the controller. I like to have a controller who "controls" all the data needed for the view layer.
If you think about using dust templates in the browser (so ajax calls from the cleint) both ways in my point of view are reasonable from an architectural view.
But I would ask my self some question about user experience before deciding:
How much time would take to complete all the calls from the
controller? Sometimes is better to send partial data to the user and
give to him something to view and load other components later for a
better user experience. But if the overhead is not over some ms, I
would decide to build my page context all in the controller.
Where is the data displayed in the page? Do you need it in the first
part of the page? Or user should scroll to view other sets of data?
If the data is not consumed immediately I would decide to leave it
to the client.
I am currently using ExtJS 3.4 to create the components of my portlet, and upon saving I wish to set the information into PortletPreferences. I understand how to set and get them via the Java code, but I am struggling to set and get the preferences via JavaScript.
I encode my JavaScript object by using Ext.encode(), but then I am stuck on saving that JSON String.
Any help is appreciated :)
Unless LifeRay provides an AJAX API to save portlet preferences you will need to create something similar yourself.
The serveResource method is there to help manage AJAX requests for portlets. You can send the portlet preferences you want saved to a resourceURL and process them serverside in the serveResource method.
That's the closest way you can save them via JavaScript. Otherwise the typical method is to submit a form to an ActionURL and save the preferences in a processAction method.
When i request a page, I need to get the returned data and changed it before viewing it
How can i do that in Awesomium?
It depends if you are using Awesomium with C++ or C#.
Awesomium for C++ provides a ResourceInterceptor class to intercept requests and responses:
ResourceInterceptor API for C++
Unfortunately, Awesomium for C# doesn't provide the same thing. There is only an interface to catch Requests, but no equivalent for catching Responses.
IResourceInterceptor API for C#
Different possibilities from here:
Tweak Awesomium for C# to implement this
Use a 3d party tool like Fiddler to intercept and modify requests/responses
In the latter case, you can find useful resources here:
Is it possible to intercept the content received within a wpf browser control?
WPF webbrowser's LoadCompleted event
I try to call XSP._isDirty() for XPINC but it does not work. In the browser everything works fine. Is there a trick how i can use it.
Is there a way how i can see clientside errors when i'm executing XPages in the Notesclient?
Two questions here.
Q1. XSP._isDirty()
XSP._isDirty() is an internal call. From the XPages portable command guide (page 156).
XSP._isDirty() : Used internally by the Dirty Save feature— see the <xp:view> properties for enableModifiedFlag. This is a private function.
Code for this call is in the file xspClientDojo.js (look for the uncompressed file on Domino/Notes).
As it is an internal call it is used at risk. There is no guarantee it will work as expected in later versions.
The enableModifiedFlag is an XPage attribute that allows you to mark the page as dirty and prevent the user accidentally leaving the page. There are more details about this on the Infocenter.
Q2. Client side debugging.
You can review client side errors using the developer panel of most modern browsers, or something like the firebug plugin. The XPages extension library comes with a Firebug Lite component you can use as well.
For SSJS and XSP engine issues you can review these in the Notes client by reading the XPages logs in the IBM_TECHNICAL_SUPPORT folder contained in the Notes data folder.
For a "live" method of this is to modify the shortcut that launches notes as follows:
Target: C:\Lotus\Notes\notes.exe -RPARAMS -console -debug -separateSysLogFiles -consoleLog
Start In : C:\Lotus\Notes\framework\
Change the path to match your clients install.
I want to call a webservice using http post/get in my html webpage using javascript.
Link is shown below,
http://www.webservicex.net/globalweather.asmx/GetCitiesByCountry?CountryName=Nepal
It is a cross domian call and i want to call it directly on my webpage,
I want to access the data of this link using javascript.
Thanks in advance.
If you don't control that domain, and I'm guessing you don't. You will need to create a web application that can act as a proxy and call this xml code server side. (As there are no cross domain restrictions)
You can then call your own web application via an AJAX request on the frontend.