简体   繁体   中英

How can I pass an argument from a web page that is loaded inside a web browser applet in a C# program, back to the C# application?

This is a probably a dumb question but here is what I've got.

A web developer has a secure login page that after a user logs into it, a database reference is made and it grants rights to a particular PDF file on our network. There is desire to have a custom locally designed application used to present that PDF file to the user, which is fine as I have used cpp code from Adobe to generate a stripped down viewer, however the problem I'm faced with is integrating his web application into my windows application.

It would be easier for me to just create my own login/database query, but then I'd basically be removing his entire piece of the project. That in itself presents a problem, as really this entire thing is his project and he asked me for help. So that's why I'm stuck with this situation where I"m attempting to insert a web applet in the application to present his login page. From that login page, after it authenticates, he can return a path to that particular file. He was previously just launching the associated PDF viewer (Acrobat), but what we need is a fully integrated solution. Make sense?

InvokeScript.

http://msdn.microsoft.com/en-us/library/cc491132.aspx

Have the webmaster write something like this:

<script type="text/javascript">
function getPdfPath() {
  return "/path/to/my.pdf";
}
</script>

You should then be able to:

var path = (string) oWebBrowser.InvokeScript("getPdfPath");

Alternately, you could have him write you a web service.

Have a look at the ObjectForScripting property of the WebBrowser. It allows you to define an object whose methods can be called by Javascript code

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM