ASP.NET Conversion to Fully AJAX Based Application - javascript

I am in charge of converting an ASP.NET web application into fully AJAX based application. I know Javascript and Jquery very well.
Initially I thought to point every anchor tag's click event to JS function and to call stuff via ajax and to populate the body and so on. I encountered a problem when it came to ASP.NET Form on every page and when there was need to make a post-back. I decided to point every Form tag's onSubmit event to a JS function to post stuff using ajax and to get results and I got to know this is not possible with ASP.NET as every time where is a button click, there will be post back so it's hard to let page know what button was clicked.
I then decided to use ASP.NET built-in AJAX controls to use with Forms which is pretty easy and worked like the way they should.
Now I am stuck with the question of which I should go with?
I like to be JS way because it's more customizable than AJAX.NET. I highly need your suggestions.

I don't see a problem in using ASP.NET Ajax. The scriptmanager and UpdatePanel controls will make you task easy and fast to convert to and ajax enabled website.
I am not sure what kind of customization you are looking for but you can still use js way whereever necessary. One another plus point with ASP.NET Ajax is it is well tested and used by thousands of sites and comes with lots of controls like in ajaxcontrol toolkit.

If you want to convert a web forms application completely to JavaScript coding, this is going to be really hard to do. It would be a lot easier to use the updatepanel control to make it look asynchronous to the user, as this doesn't break the server-side integration. But if you are using JS to post back to the server, then wipe the UI and replace it with the new one every time, that's going to be a lot harder.
Ideally, the best way is to use web services, call the web services through JS code (either JQuery or using the Sys.Net.WebServiceProxy ASP.NET AJAX object) to stream the data and you build the client in JS.
Let me know if you want more info...
HTH.

Related

Use an external webpage's form from my own website to get data (PHP)

I wonder if I can use an external form of a webpage in the web from my own website. I am creating an application using the WAMP tool and I need some PHP/JavaScript/whatever script to do it.
Basically I'd have the same exactly form in my website (or at least a similar one) as the one in the external webpage - the goal of this form is only to perform a search. The user would be capable of doing the search and seeing the results posted in my website aswell and all this happening in a hidden way.
I really have no idea how to do this as I searched stackoverflow and the web looking for a solution but it really seems a little bit complicated.
Here's an image to ilustrate more or less what I want:
edit: I don't want any script or code! I Just want to know what is the best way to do this. I will eventually come to a solution (I hope!). Thanks!
The concept is called Web Scraping, you can find more about it in https://en.wikipedia.org/wiki/Web_scraping
As an answer, you can write simple web scraper using PHP CURL.
CURL can submit a remote form for you and get the results of form submit, that results may need to be handled by your script to be displayed in the form you need.
This stackoverflow question and answer may clear it more for you.
How to submit form on an external website and get generated HTML?

What is the best way to display xml information on a web page?

I've currently got a service that produces xml files every 10 seconds containing server information. I'm looking for a way to display this on a web page.
I have been looking on the web for the best way to do this and it seems that using AJAX would be good as it allows the loading of dynamic content to be done in the background.
However how can i use AJAX? Should i add a ASP.NET website to my visual studio project? OR should i look to use javascript & AJAX in something like dreamweaver?
I'm very new to programming so i only really have a bit of experience in vb.net.
Any help would be much appreciated!!
I'd use an ASP.NET page and use the built-in AJAX ScriptManager and UpdatePanel controls. They are very easy to incorporate.
Also, you don't want to bombard people with Raw XML, so learn to use XSLT. I would suggest rendering it on the server using the XSLCompiledTransform. Do this on the server, as you can mix and match the ASP.NET controls and HTML server controls. I would suggest creating a <div runat="server">, place this in the UpdatePanel, and render XML via XSLT to this.
I'm not a .net developer so i don't know nothing about .net controls. But maybe you should take a look into jQuery and its ajax capabilities.
http://api.jquery.com/jQuery.ajax/

Best way of dynamically loading server controls from jQuery/Javascript

I have seen a few other questions of a similar vein on here, but with no definitive answers.
I am looking for the best way to go about loading asp.net server controls (or user controls) from client script (likely jQuery). I am creating a small dashboard that will feature multiple controls/controls created as the result of client script call's and the controls will need to be able to run server side functions and are not just simple information display controls.
I have done something similar recently with loading details controls which were rendered via an HttpHandler from a jQuery $.get() and the resulting HTML of the control is injected into the DIV area - however these used a custom formless page as a temp placeholder as to not interfere with the current viewstate/rendering cycle on the page so they were only able to use HTML elements such as hyperlinks, etc.
This is different and I am looking for the best way to be able to load up controls which will act as if they were registered into the page at the beginning of the page life cycle because I want the controls to be able to run their own server side methods/events (some filtering, etc).
I have seen some people say you should really use UpdatePanel's for this and do the processing server-side - but I am loathe to do this as one of the requirements is heavily tied to using client script.
I have experimented some with this and feel that ASP .Net stateful behaviour of the server side controls is really restricting when it comes to things like this.
If it is a simple dialog such as a login with username and password I can recommend that you do either a page method or a ashx handler that the javascript can communicate with, and then just build all the markup + server communication with your client side script.
But since you are building a more complex solution I would give you the advice that people already have suggested: Use UpdatePanels.
You can always hook up client scripts that run before the postBack (which shows the server side controls) is triggered, this client script can control if the postBack should fire or not etc. And you can also make the server side of the code invoke client side scripts when it have been rendered.
Things like this make you really appriciate ASP .Net MVC.

Styled Javascript Popup that Conncects to Database

I want to create a javascript popup box that contains text fields. I want to be able to style this box - using CSS - and I want the textfield entries to be Inserted into a MySQL database. Is this possible?
I would be familiar with doing this through web forms and server side scripting but I need it to be a bit more client side this time to make things seem a bit faster. I am thinking I may need to learn some AJAX but any pointers would be a help.
GF
You don't need to learn that much Javascript, to be completely honest. You could simply create a small HTML form on your page, and display it as a popup. You could either have it send the data to your server-side script via the form's natural submit, or you could pass that information asynchronously.
jQueryUI has an example of something very similar: http://jqueryui.com/demos/dialog/#modal-form
You can't connect to a database with client-side javascript. Ajax will help you make seamless calls back to the server without refreshing pages, but you will need to have a server side component to return something useful back to your javascript.
As far as styling your forms with CSS, that part is doable.
Best way to do this would be to "popup" a new window which points to a file with the AJAX calls, the form, and the styling.

Excel files in ASP.Net MVC

Is there any way to use server controls in ASP.NET MVC?
Specifically I need to use the FarPoint Spread control in my application to display an Excel file that exists on the server with the ability to display updates on the client in real time.
The reason that I want to use MVC instead of webforms is that eventually we're going to scrap the excel files and create the views programmatically but I have to display these files now since we don't have time to create that functionality in this phase.
My suggestion would be to use WebForms for pages that need the custom control and MVC for everything else. In order to mix WebForms in MVC in the same application you'll need an IgnoreRoute call so MVC doesn't try to process .aspx files and you need to make sure everything needed for WebForms gets added to the web.config. Scott Hanselman has a great blog post here with the details.
FarPoint recently released a Spread component which is supported on the MVC platform .You can go through which blog which gives detailed information on using Spread with MVC 3 .I hope this helps.
http://www.gcpowertools.info/2011/12/using-grapecity-spread-for-net-with-mvc.html
I'm not sure how FarPoints control works, but if its anything like the aspose cells component I use, I dont think you'll have any problem.
As far as I'm aware, theres nothing to stop you using normal webforms controls anywhere in your MVC app, it's just that most rely on ViewState and the postback model (which arent present) and hence don't work properly.
There isnt really any UI rendered for the aspose excel control, so you should be able to just create an object, call some methods to set things up and then stream the generated file out to the response just the same way you would in a button click event.
This is all hypothetical, and I apologise in advance if this doesnt work!
Paul.
http://www.tumelty.com/

Categories