usually when I programming a web application with java I use DWR library to enables Java on the server and JavaScript in a browser to interact and call each other.
for example, I can call a java routine to access the DB directly from a javascript code, and this is really useful.
Now I'm trying to create a web application with visual studio 2012 and I don't know if I can do the same thing with asp.net.
I've tried some "googling" but i don't had success.
Someone can help me?
Thanks and sorry for my bad english >.<
You can access the server side code by using javaScript.
There are some good links on this site.
Based on my experience, i found this web service to be a very useful tool.
1. You must have a web service or asmx. (check how to create here).
2. Use jQuery or other method of Ajax POST to communicate with the web service.
$.ajax({
url: "/location_of_your_webservice/ASMX_FILE.asmx/backend_method_or_function",
...
Or if you just have to fire a button click that triggers the backend event then you might want to check this.
Related
I have created an interactive quiz using html and javascript which will be run on a touchscreen at an event and I need to write the results to a local csv file (so no internet connection). It needs to write to an already existing file, so it cannot be done where the data is stored locally and a download link is generated through the browser.
How would I go about doing this? All methods I have found are either unreliable or no longer supported. The browser I am using is Chrome, so it does not need to be cross-browser compatible.
Can anybody help or point me in the right direction please?
Install a web server.
Point the browser at http://localhost.
Send the data to the server using Ajax or a form submission.
Process the data (including storing it in a file) using the server side language of your choice.
When javascript is used only in the client-side cannot write data as you want.
Follow the #Quentin recommendation about install some web server, as apache using php for instance(It is pretty straight forward!). I also recommend you to create restFull methods to do it with jquery calls from the client side, it is easy to find many examples in the internet and quicky...
If you want something more easy you could work with html post using forms in php, the most easy way to do it.
I've made a program in Python 2.7 with a wxWidgets GUI. Now, I want to improve it by making a web GUI, make it multi-platform and port it in Python 3.4. For this purpose, I have to make Javascript and Python communicate (i.e : I want my Python to react on some event on the page and I want my page to react on some Python actions).
I don't really know how to do it, and I don't even know if it's possible.
I've find some libraries, but some are just for Python 2 (pyjamas), and some don't provide what I search, or I don't search enough ^^ (web2py, turbogear, cherrypy).
I would like to find a complete library that ease this communication, and that is rather known and supported, with a compete documentation.
Maybe, there are other ways to do such a web GUI, but I don't find them.
Thanks !
I guess what you want is a single page application.
I would suggest to wrap your python code in a RESTful Api using a python web framework like Flask. This would isolate your python code from the presentation layer.
You could then write the UI in html and javascript and use AJAX to call your python api from javascript.
I have VB.NET code that handles automation of various application installs. I want to move this essentially out of a VB generated EXE package, and be able to execute the same code (or the equivalent result) from an HTML page on a server. Is this possible? It looks like javascript can't cross the web application/desktop application barrier. Perhaps I can execute the VB.NET code/application that handles the automation (stored server side) from code in the HTML? This is a fairly broad question(s) so ideas are welcome. Please post examples with your ideas!
Thanks.
Ian's comment made me read the question again. If you really plan to execute code on the client through a web browser, please ignore this answer.
You can use any server-side language that you want to do this. Since you already wrote it in VB, you can use ASP.NET or PHP's exec(). Example:
<?php
if($_GET["dosomething"]) {
exec("mycommand");
}
will execute mycommand when you pass dosomething as a paramter to the file.
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/
I'm writing a web crawler (web spider) that crawl all links in a website.
My application is a Win32 App, written in C# with .Net framework 3.5.
Now I'm using HttpWebRequest an HttpWebResponse to communicate with the web server.
I also built my own Http Parser that can parse anything I want.
I found all link like "href", "src", "action"... in the parse.
But I can not solve one problem: Simulate Client Script in the page (like JS and VBS)
For example, if a link like:
a href = "javascript:buildLink(1)"
... with buildLink(parameter) is a Javascript function that will make a custom link due to the parameter.
Please help me to solve this problem. How to simulate JavaScript in this app? I can parse the HTML source code and take all JavaScript code to another file, but how to simulate a function of it?
Thanks.
Your only real option is to automate a browser. As other answers have said, you cannot reliably simulate browser javascript without having a complete DOM.
There are fortunately ways to automate the browser, check out Selenium.
It has a C# API, so you can control the browser from C#.
Use your .NET web crawler code to crawl the site. Whenever you encounter a href="javascript:... link, handle the page containing the link in Selenium:
Use the Selenium API to tell the browser to load the page.
Use the Selenium API to find all links on the page.
This way, your spider only uses Selenium when necessary (pages without javascript links can be handled by the browser-less spider code you already got). And since this is an embarrassingly parallel workload, you could easily have multiple Selenium processes running at the same time (either on one computer or on other computers).
But remember that href="javascript is hardly the only way a page can have dynamic links. The more common case is probably that a onload or $(document).ready() script manipulates the DOM and adds links that way.
To catch that case (and others), the spider probably will have to use Selenium for all pages that have a <script> tag.
You are basically pretending to be a browser, except that HttpWebRequest only does the networking stuff for you.
I would recommend using the ie web browser control and interop'ing into that from your c# application. That will allow you to run JavaScript, set variables, post, etc etc.
Here's some basic links I found after a search for "ie web browser control":
http://www.c-sharpcorner.com/UploadFile/mahesh/WebBrowserInCSMDB12022005001524AM/WebBrowserInCSMDB.aspx
http://support.microsoft.com/kb/313068
This is a problem which is not easily solved. You could consider taking one of the existing JavaScript implementations and porting or interfacing with it somehow.
If I were tackling this problem, I'd probably build a small side application in Java on top of Rhino, with some sort of RPC framework layered on top of that so that I could communicate with it from my primary application.
Unfortunately, without having a complete DOM implementation on top of that, you would be limited to only very simple javascript.
You could execute the javascript by using the MS JScript engine or something similar.
MSDN Reference
Eric Lippert's blog on using Eval (part 1) (part 2) (part 3)
This isn't guaranteed to work, especially if the javascript tries to access the DOM, or somesuch... But for simple scripts, it might be enough.