C# with HTML forms - c#

Am developing a windows phone app using C#.
There is a web browser displaying HTML form containing radio buttons.
Is there any way of getting the selected button value to be used in C# and based on that selected button value, I can decide which events has to be occurred further.

You can communicate between an html page and C# code using JavaScript. In fact, you can inject a js into your HTML page to retrieve the selected item, and pass the parameter back to a C# callback. See this answer for more information.

Related

Insert Data from Windows Form to a html Website in C# and get the output

I am doing a project in which I have to make a windows application that will have some texboxes and checkboxes and these has to be filled by the user. I want to use this information and to automatically fill some fields in a Website when I click on a button, in my windows form.
I'm quite new to the subject and I have searched and found some ways that maybe I can do it, but I'm not sure how to do it. I heard about Web Client, Web Request and Web Response, and also HTML Agility Pack. The site is http://re.jrc.ec.europa.eu/pvgis/apps4/pvest.php#.
I want to fill some of these fields and checkboxes with the information that I have in my Windows Form, and then click the calculate button and save the output. What is the best way to do that? I'm programming in C#.
Thanks for your time.

How can I get HTML element onClick from WebView in Windows 8 Metro app?

I have a simple Win8 Metro app which has three pages, one of which is WebView.
Let's say that I have some html code that I'm showing in WebView that contains something like
Go to site
How can I detect click on that HTML element, recognize element and get data (let's say "http://www.mysite.com") from the element?
Is that even possible in Metro apps?
Thanks in advance.
Use these members:
LoadCompleted - to wait until your page is loaded,
InvokeScript - to subscribe to an event inside HTML,
ScriptNotify - to be notified from JS.
If you control the content for mysite.com, it can be done. You can add Javascript on your site to fire an event via window.external.notify that can raise an event in your C# using WebView.ScriptNotify. See How to receive information from the WebView in this article for an example.
Unfortunately, there is no way to intercept navigation (unlike other web views).

Forms - How to POST default field values in C#

I'm debugging an html form. I need to POST the form with the default values (some of the field values are set with JavaScript).
How can I do this programmatically in C#? I want to have an action similar to pressing the "SUBMIT" button. I'm using a WebBrowser of my own.
Thanks.
You could do it via JavaScript in the HTML, or the browser developer tools:
document.getElementByTagname('form').submit();
Just put that in a script-tag at the bottom of your HTML, and it will post the form. Not really sure why you can't just click the "submit" button, though..
I suppose what you want is to submit your form with the default values, though it needs to be submitted through server side i.e. c#?
You can avoid any client side processing for your form by changing certain attributes of the form tag. This post has some useful information for your taste.

combo box change event not firing via Inserted jquery script into c# web browser control

I have a web browser control in a C# app that upon page completed it inserts a script into the document.
The script is to change a combo box value for automation.
The thing is when the script is executed the normal behavour of the original site is not working. It is meant to load some results via AJAX.
Though if I click and change the combo box using the mouse it does work.
The script is like this
$("#orderBySelect").val('prfs'); $("#orderBySelect").click();
Though I have tried the change event also as well as a combination of other events including the click event on the selected option.
Any idea why this would be?
If "orderBySelect" is an ASP.NET UserControl (i.e. it has runat="server"), ASP.NET will silently modify that ID (by prefixing a string to it) when it flushes the HTML to your browser.
Generally I work around that by using this instead:
$('[id$="orderBySelect"]')
which basically says "the element with an ID that ends with "orderBySelect".

Simulate keyboard on another web page from my web page?

I would like to display another web page within a web page... maybe using framnes, then be able to simulate mouse clicks/keyboard input randomally on this new page that is within my page.
Is this possible using asp.net/ javascript or any language. asp.net preferred
Thanks for any input
I dont think it is possible on client. If you are creating a desktop application then may be it could have been done like in automation, but on clint side even javascript cant create events like mouse clicks, it can only handle such events. however you can insert text in text boxes by traversing and accessing DOM in your javascript.
Its Definitely not possible from Server side in ASP.Net

Categories

Resources