I am developing a project using Xamarin.forms. I need to get data from webservice and then need to show that data on WebView HTML page. Suggest me any Xamarin.forms inbuild function or any renderer class to implement this feature.
To send data from C# page to HTML we need to call javascript function defined in that HTML file.
We are having Eval function in Xamarin Forms.
WebViewObj.Eval(string.Format("JSFunctionName({0})", DataInStringFormat));
By using above function we can send the data to JavaScript function.
You probably want to look at the documentation for creating a HybridWebView.
This document describes how you can create your own kind of WebView which can handle JavaScript events for you. Although it may not be 100% accurate to what you want, it will give you an idea and you can pick it up from there.
As you noted in the comment you need to implement C# to JS. In the same custom renderers you can call functions for this on the WebViews.
For iOS you can use InvokeJavaScript(); and for Android (mis)use LoadUrl("javascript: alert('Hi!');").
For more info on this, follow this great post by Adam Pedley.
Related
I want to generate screenshots of a website using its URL.
This I want to create using ASP.NET and C#, and I dont want to use any of the available tools and API(Url2Png, Wesnappr, Awesomium etc..).
Which classes of ASP.NET and C# should I explore for this ? How should I start about on this ?
Please can someone guide me on this.
Looks like fun project to do by hand...
Read W3C site for HTML and CSS specifications (4+5 for HTML and 1+2+3 for CSS)
Implement your own HTML engine
Read ECMA specification to learn inner workings of JavaScript. Also dont forget to check for specific implementations for most popular browser(s) for you.
Implement your own JavaScript engine
Tie HTML and JavaScript engines togehter
Now when you have a way to safely render HTML on server it is an easy task: Get your engines to render page into a bitmap (may also need to implement cutom grapics library) and you are done.
More seriously - use existing tools (make sure they are ok to be used on server - i.e. I would not do it with IE engine). Or if you want to learn some particular part of the stack - scope the rest down (i.e. just render title of the page to bitmap using System.Drawing) to see how components work together.
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.
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/???)
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)
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.