I am using the Nancy Web Framework in my C# Console Application to basically create a Web Administration panel for my software. I have opted to use the Spark View Engine, as it is basically just HTML. I basically want to create a chatbox, except pull the data written to my application's console every X seconds and display it in a box instead.
I have very little experience with JQuery and AJAX, but they aren't overly complicated from the examples I have seen. The issue I am running into is that ALL of the chatbox and shoutbox examples use PHP.
I basically just need something like this...
The only difference is I need to pull the information from my application instead. I can use basic C# methods inside of the HTML (and probably inside of javascript but I haven't tried this). What would be the best way to do this, and are there any examples floating around that don't use PHP?
This was completed using AJAX and JSON.
Well, to use HTML for styling inside some PC program is just not wise. It has much better UI engines, though. But for your information here is nice jQuery shoutbox tutorial, but well, you only need to handle data input and output with C#, so actually I see no problems. The engine which you are using should have some kind of data stream, or requests handler (bla://program/???)
Related
I have googled this with a couple of differing terms and I could not find my solution. What I want to do is to manipulate a webpage by editing its source, for example removing a part from the code maybe a div or so. I know how to get the source of a webpage and know how to change the code but I have no idea how to manipulate the page instantly, by for example removing an element.
Your help would be appreciated!
If you want to manipulate client code (HTML) what you need is Ajax.
You can use JQuery javascript library to manipulate html of a page adding, editing and removing html tags, scripts, etc.
Here you can find a decent tutorial as a start point.
If you want to manipulate server code (C# codebehind) what you need is creating a web project in visual studio (ASP.NET Web Application)
EDIT: As commented by #CSharpened both solutions are not mutual exclusive. You can have an ASP.NET Web application that uses Ajax to manipulate UI. In fact lot of people does that.
I would consider using AJAX. You can use either javascript or jquery coupled with html, asp.net and C# to achieve the results you are after.
For simple editing like removing divs or collapsing menus etc simple Javascript or jquery will suffice. However changing the coding of the page requires you to use AJAX or similar.
Hi i want to create a widget which can be embedded on other websites similar to the twitter profile widget, an example is here;
http://twitter.com/about/resources/widgets/widget_profile
The way i would approach this is to return the data in json format via my wcf, the problem is looking at the twitter example there seems to be some javascript and i am not to clued up on the purpose. My question to the more experienced devlopers is am i on the right track and what else will i need to do. Thanks alot
The purpose of the javascript would be to actually call your wcf service to retrieve data and write the html results to the screen. In the twitter example, many options are set inside a javascript object that is used to manage the configuration (background color, username, etc). You can return json, and then take the values from json and plug them into an html template on the client side. If you want this to be used on other sites however, I would probably avoid the use of jquery as you can't be sure the user has included it, and so you would need to include it. And then you have versioning issues if you use an older version, and the website your widget is on wants to use a newer version.
There is an interesting blog post that explains how to create a widget, loading jquery and css safely, making JSONP calls and more:
How to build a web widget (using jQuery)
I have been given a task to crawl / parse and index available books on many library web page. I usually use HTML Agility Pack and C# to parse web site content. One of them is the following:
http://bibliotek.kristianstad.se/pls/bookit/pkg_www_misc.print_index?in_language_id=en_GB
If you search for a * (all books) it will return many lists of books, paginated by 10 books per page.
Typical web crawlers that I have found fail on this website. I have also tried to write my own crawler, which would go through all links on the page and generate post/get variables to dynamically generate results. I havent been able to do this as well, mostly due to some 404 errors that I get (although I am certain that the links generated are correct).
The site relies on javascript to generate content, and uses a mixed mode of GET and POST variable submission.
I'm going out on a limb, but try observing the JavaScript GETs and POSTs with Fiddler and then you can base your crawling off of those requests. Fiddler has FiddlerCore, which you can put in your own C# project. Using this, you could monitor requests made in the WebBrowser control and then save them for crawling or whatever, later.
Going down the C# JavaScript interpreter route sounds like the 'more correct' way of doing this, but I wager it will be much harder and frought with errors and bugs unless you have the simplest of cases.
Good luck.
FWIW, the C# WebBrowser control is very, very slow. It also doesn't support more than two simultaneous requests.
Using SHDocVw is faster, but is also semaphore limited.
Faster still is using MSHTML. Working code here: https://svn.arachnode.net/svn/arachnodenet/trunk/Renderer/HtmlRenderer.cs Username/Password: Public (doesn't have the request/rendering limitations that the other two have when run out of process...)
This is headless, so none of the controls are rendered. (Faster).
Thanks,
Mike
If you use the WebBrowser control in a Windows Forms application to open the page then you should be able to access the DOM through the HtmlDocument. That would work for the HTML links.
As for the links that are generated through Javascript, you might look at the ObjectForScripting property which should allow you to interface with the HTML page through Javascript. The rest then becomes a Javascript problem, but it should (in theory) be solvable. I haven't tried this so I can't say.
If the site generates content with JavaScript, then you are out of luck. You need a full JavaScript engine usable in C# so that you can actually execute the scripts and capture the output they generate.
Take a look at this question: Embedding JavaScript engine into .NET -- but know that it will take "serious" effort to do what you need.
AbotX does javascript rendering for you. Its not free though.
I'm writing a WinForms application that sends email messages (like a mail merge).
I'd like to use ASP.Net's rendering engine to render the HTML bodies of the messages.
What's the simplest way to get the rendered output of a single ASPX page without the entire ASP.Net runtime?
To make things harder, I'd prefer to compile the ASPX at runtime so that it can be modified without rebuilding the application. However, this is not a requirement; if it's too difficult, I'll give up on it.
Rick Strahl posted an article how to do this at this location: http://www.west-wind.com/presentations/aspnetruntime/aspnetruntime.asp. I know there is a way to call some internal .NET Framework methods but I can't remember what they are off hand.
You may want to consider using a templating lib like NVelocity. Using the WebForms rendering engine in this manner is a bit overkill and hackish at best.
As an aside: keep in mind that HTML in email sucks. Even the most elementary of CSS is ignored by the majority of email clients. If you want my advice, KISS and save your sanity: if you're going to automate emails, send only plain text.
how do i make an autocomplete textbox in asp?
but i need to get the autocomplete data by querying the database.
I dont really know how to explain this, sory if theres not enough detail.
i cant use ajax, because i think i will have compability issues with my old app.
so im thinking of doing this using java script. or is there a way to do this by using .net?
im using C# for codebehind. thanks
It's going to be a lot of effort without using some third party autocomplete I think - not sure what you mean by 'I can't use ajax', but how about using the ASP.NET AJAX autocomplete control, setting the ServiceMethod property to a static Page Method in your code behind? That keeps it contained within your page at least.
The Page Method can go off to your database, and return a String[] of results.
If you decide to use it, you'll need to set the EnablePageMethods property to true in the <asp:ScriptManager> control.
AJAX is JavaScript. It's JavaScript using the XMLHttpRequest object to make the asynchronous request. Here's an article about it and ASP.NET.
If you want to know more about AJAX, (Asynchronous JavaScript and XML), I'd check out Wikipedia first. If you want books on it, there are a ton. I recommend Programming ASP.NET AJAX by Christian Wenz (O'Reilly And Associates).
if you dont want to uses ajax library, try jquery
there are many plugin autocomplete or suggest textbox for jquery
try this one
http://www.vulgarisoip.com/2007/08/06/jquerysuggest-11/
The ASP.NET AJAX framework works for ASP.NET 2.0 & above. As such it will not work in Visual Studio 2003 environment.
Anthem.NET is a free, cross-browser AJAX toolkit/framework for the ASP.NET development environment that works with both ASP.NET 1.1 and 2.0 -
http://sourceforge.net/projects/anthem-dot-net
For your autocomplete requirement, you can consider using the jQuery Autocomplete Plugin
It requires very less programming. Check the demo & code sample here - http://docs.jquery.com/Plugins/Autocomplete
It's autocomplete() method takes a URL or array to populate your autocompletion list. You can pass the URL of the page that fetches the results from the database directly.