Integrate a C# form

Use this board to ask questions or have discussions with other Rich Displays users.
Post Reply
Pickeroll
New User
Posts: 4
Joined: Tue Feb 20, 2018 10:32 am
First Name: Filippo
Last Name: Mazzarello
Company Name: Progetto Adele
Contact:

Integrate a C# form

Post by Pickeroll »

Hey, I'm new to this forum and this environment.

I'm trying to integrate inside a display an external form made with Visual Studio, the file is named Login.application.

The code is basically this:

Code: Select all

private void button1_Click(object sender, EventArgs e)
{
    var menu = webBrowser1.Document.GetElementById("SomeItem").InvokeMember("click");
    webBrowser1.Visible = true;
    button1.Visible = false;
}

private void Form1_Load(object sender, EventArgs e)
{
    webBrowser1.Visible = false;
    webBrowser1.Navigate("someUrl");
}
First of all: is this possible ?

I know that in this environment there is a native integration with JS, but I found some cross origin problems while I was trying to navigate the DOM inside an iframe.

Looking for hints and a smart way to do it.

Thanks for the help.
User avatar
Megan
Profound Logic Staff Member
Posts: 90
Joined: Mon Sep 11, 2017 12:15 pm
First Name: Megan
Last Name: Bond
Company Name: Profound Logic
Phone: 5623227473
State / Province: California
Zip / Postal Code: 92692
Country: United States
Contact:

Re: Integrate a C# form

Post by Megan »

Hello Pickeroll,

Thank you for writing in! Could you please describe what it is you are trying to do with the iFrame in more detail? Perhaps we can help you with your problems navigating the DOM inside an iFrame.

Thanks,
~MEGAN BOND
Technical Support Specialist
support@profoundlogic.com
Pickeroll
New User
Posts: 4
Joined: Tue Feb 20, 2018 10:32 am
First Name: Filippo
Last Name: Mazzarello
Company Name: Progetto Adele
Contact:

Re: Integrate a C# form

Post by Pickeroll »

Megan wrote:Hello Pickeroll,

Thank you for writing in! Could you please describe what it is you are trying to do with the iFrame in more detail? Perhaps we can help you with your problems navigating the DOM inside an iFrame.

Thanks,
Thanks for the reply.
My aim is to integrate a form from an external website, I don't have the direct url of this form so I've put an inframe and tried to access to the DOM of it and navigate with .click() command, the problem was that the DOM of the iframe resulted to be blank.

I've opened some topics on Stackoverflow but the replies weren't encouraging.

https://stackoverflow.com/questions/488 ... javascript
Scott Klement
Experienced User
Posts: 2711
Joined: Wed Aug 01, 2012 8:58 am
First Name: Scott
Last Name: Klement
Company Name: Profound Logic
City: Milwaukee
State / Province: Wisconsin

Re: Integrate a C# form

Post by Scott Klement »

I'm not familiar with C#, but I think what you're asking is more related to JavaScript than it is C#, correct? You're inserting JavaScript code into a page that is trying to read the contents of an iframe.

Normally, JavaScript code can only access the contents of a different iframe if it comes from the same "origin" (by "origin", I mean the same host/port.) There is a way to override this, but only if access is granted with special HTTP headers (and I'm not certain whether that is available in all browsers.) You cannot normally access contents in an iframe from a different origin because this would allow rogue web sites to steal your personal information. Since this would be a huge security problem, web browsers specifically look for it and block it.

I've glanced over the StackOverflow link you posted, and it looks like the responder over there said the same thing.
Pickeroll
New User
Posts: 4
Joined: Tue Feb 20, 2018 10:32 am
First Name: Filippo
Last Name: Mazzarello
Company Name: Progetto Adele
Contact:

Re: Integrate a C# form

Post by Pickeroll »

Scott Klement wrote:I'm not familiar with C#, but I think what you're asking is more related to JavaScript than it is C#, correct? You're inserting JavaScript code into a page that is trying to read the contents of an iframe.

Normally, JavaScript code can only access the contents of a different iframe if it comes from the same "origin" (by "origin", I mean the same host/port.) There is a way to override this, but only if access is granted with special HTTP headers (and I'm not certain whether that is available in all browsers.) You cannot normally access contents in an iframe from a different origin because this would allow rogue web sites to steal your personal information. Since this would be a huge security problem, web browsers specifically look for it and block it.

I've glanced over the StackOverflow link you posted, and it looks like the responder over there said the same thing.
Thanks for your reply Scott.
Javascript was as a matter of fact my first try, but then I run into the problems described by you and the StackOverflow community.

So:
- I created a Windows Form Application
- Installed it on my Server (it works)
Image
- Tried to Run it following this page: http://www.profoundlogic.com/docs/pages ... d=26607685
- I tried by using this notation:

Code: Select all

var command = "C://Users//filip//Desktop//Taric//Login.Application"; -> or Setup.exe
pui.runPCCommand(command);  
or by calling directly:

Code: Select all

pui.runPCCommand("Login"); -> "Login.Application" -> "Setup.exe"
I tried also with the example but no windows alert appeared, so maybe I'm missing something.
Image
Pickeroll
New User
Posts: 4
Joined: Tue Feb 20, 2018 10:32 am
First Name: Filippo
Last Name: Mazzarello
Company Name: Progetto Adele
Contact:

Re: Integrate a C# form

Post by Pickeroll »

Now following the Desktop path I successfully launched the application, but It works only one time then in order to launch it again I need to clean my cookies.
Scott Klement
Experienced User
Posts: 2711
Joined: Wed Aug 01, 2012 8:58 am
First Name: Scott
Last Name: Klement
Company Name: Profound Logic
City: Milwaukee
State / Province: Wisconsin

Re: Integrate a C# form

Post by Scott Klement »

Hi Pickeroll,

Previously you were referring to running a web page in a separate iframe.

Now you are showing me the path to a Windows program, so I am getting confused. Is this a separate question? Or have you replaced the web page with a Windows program?

The pui.runPCCommand() runs a Windows command, so needs to be in the syntax that Windows expects it. Some of your earlier examples are using foreslashes (the "/" character) in the path, and I don't think Windows supports that. The final example (in the screenshot of the Subfile Row Onclick event) correctly uses the backslash ("\" character) and it looks like it should work.

You mentioned something about clearing cookies, and I don't understand why that would matter. pui.runPCCommand() does not use cookies at all.

Perhaps it would help if you explained how you are running this? Are you using the PC Command Launcher? The PC Command Listener? or the Java applet?
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 3 guests