在ASP.NET Web表单中触发单击事件和读取外部URL的IFrame源 [英] Firing Click events and Reading IFrame Source of External URL in ASP.NET web form

查看:62
本文介绍了在ASP.NET Web表单中触发单击事件和读取外部URL的IFrame源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好


我开发了一个Windows应用程序(C#Windows窗体),它将获取使用Webbrowser Control导航的页面的IFrame源代码。现在我想在ASP.Net Web应用程序(C#Web窗体)中执行此操作。


是否有任何其他方法可以访问我的页面的IFrame源我是导航到。此外,我需要点击我正在浏览的页面中的一些链接。要求是读取IFrame源包含的数据。


我尝试在ASP.Net Web Form中使用Webbrowser Control,但是一旦将Webbrowser Control放在Web Form上,如果应用程序是运行,获取页面无法显示错误。还尝试调用已经在ASP.Net网页中开发的Windows应用程序(.exe),这也是行不通的


请有人帮我看看如何读取IFrame源和火单击它在ASP.Net中导航的页面事件。从我们的门户网站,我们需要导航到外部URL。一旦导航到externalURL,我必须点击一些点击事件并阅读IFrame源。


问候

E

Hi

I have developed a Windows Application(C# Windows Form) which will get the IFrame Source of the page it is navigating using Webbrowser Control. Now I want do this in ASP.Net web application(C# Web Form).

Is there any other method through which I will be able to access the IFrame Source of the page I am navigating to. Also I need to click on some of the links in the page I am navigating. Requirement is to read the data the IFrame source is contains.

I tried using Webbrowser Control in ASP.Net Web Form but once the Webbrowser Control is placed on Web Form, if the application is run, getting Page cannot be displayed error. Also tried calling Windows Application (.exe) which is already developed in ASP.Net web form, that is also not working

Please anybody can help me how to read the IFrame Source and Fire Click events of page it is navigating through in ASP.Net. From our portal we need to navigate to external URL. Once it is navigated to externalURL, I have to fire some click events and read the IFrame source.

Regards
E

推荐答案

HI Ej,


根据您的描述,您曾经在winform中使用WebBrowser Control

app并从外部网站导航一些页面并对检索到的页面的dom集合执行某些操作,并以编程方式在这些页面上触发一些事件

。现在你想在asp.net web

页面中移动这样的功能。你使用iframe元素来包含外部页面并且想知道

如何控制iframe中的页面,是吗?是的?


至于这个问题,这里有我的建议:

1.在网页中,我们通常可以使用javascript来操纵嵌入在某个网页中的iframe

元素。例如,更改其URL,获取其框架或docuemnt对象的
并循环其html元素collecton。

但是,这有限制我们只能执行此类操作在

页面上,该页面来自容器页面的同一个域(iframe

所在的页面)。例如我们的网页应用程序位于 www.mydomain.com 和一页

包含iframe。如果iframe的包含页面也来自同一个

域名,例如a.mydomain.com或b.mydomain.com,那么我们就可以了。

使用javascript来重新获取iframe页面的dom集合,否则,

我们将无法执行此操作(将遇到权限被拒绝错误)。这是

一些相关的技术文章:

http://www.codeproject.com/jscript/slite.asp
http://www.oreillynet.com/pub/a/java...08/iframe.html


2.如果你想实现与winform应用程序相同的功能,我认为你可以创建一个包装WebBrowser控件的Winform控件

并且还封装了所有这些功能(例如获取导航页面'

源并在其上发射一些事件)。然后,在您的网页中嵌入winform控件

。这称为IE托管的winform控件。但是,那将是
需要客户端授予在IE中运行富客户端

控制的权限。以下是IE主机winform控件的一些参考:

http://samples.gotdotnet.com/quickst...eSourcing.aspx

#将.NET WinForm控件公开为ActiveX的简单方法在任何

HTML页面中控制
http://www.codeproject.com/cs/miscct...wincontrol.asp


希望有所帮助。谢谢..


问候,


Steven Cheng

微软在线支持


安全! www.microsoft.com/security

(此帖子按原样提供,不作任何保证,并且不授予

权利。)


在ASP.NET上获取预览whidbey
< a rel =nofollowhref =http://msdn.microsoft.com/asp.net/whidbey/default.aspxtarget =_ blank> http://msdn.microsoft.com/asp.net/whidbey /default.aspx



HI Ej,

From your description, you used to use WebBrowser Control in your winform
app and navigate some pages from external sites and do some operations on
the retrieved page''s dom collection, also programmatically fire some events
on those page. And now you''d like to move such function in an asp.net web
page. You use the iframe element to contain the external page and wonder
how to control the page in the iframe , yes?

As for this problem, here are my suggestions:
1. In web page, we generally can use javascript to manipulate the iframe
element embeded in a certain web page. For example, change its url , get
its frame or docuemnt object and loop through its html elements collecton.
However, this has the limitation that we can only do such operations on a
page which is from the same domain of the container page(where the iframe
is in ). For example our web app''s in the www.mydomain.com and one page
contains the iframe. if the iframe''s containing page is also from the same
domain , such as a.mydomain.com or b.mydomain.com, it''ll be ok for us to
use javascript to requry the dom collection of the iframe page, otherwise,
we''ll be unable to do so(will encounter permission denied error). Here are
some related tech articles:

http://www.codeproject.com/jscript/slite.asp

http://www.oreillynet.com/pub/a/java...08/iframe.html

2. If you do want to implement the same functions as your winform app, I
think you can create a Winform control which wrapper the WebBrowser control
and also encapsualte all those functions(such as get the navigated page''s
source and fire some events on it). And then, embeded the winform control
in your web page. This is called IE hosted winform control. But that''ll
need the clientside to grant enought permissions to run the rich client
control in IE. Below are some referene on IE host winform control:

http://samples.gotdotnet.com/quickst...eSourcing.aspx

#Simple way to expose a .NET WinForm control as an ActiveX control in any
HTML page
http://www.codeproject.com/cs/miscct...wincontrol.asp

Hope helps. Thanks..

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx





是的,你的问题是正确的。


我尝试了codeproject中的示例,只有当usercontrol文件放在应用程序文件夹中时它才有效,如果它放在bin文件夹中,单击Button时会显示未定义的消息


现在我尝试将Webbrowser Control以类似的方式放在Webform上,但一切都没有发生。没有mesage os也会显示出来。可能是什么原因


是否还有其他方法可以通过ASP.Net Web读取外部URL源


谢谢

EJ
Yes, your undestanding of question is right.

I tried the sample from codeproject and it works only if the usercontrol file is placed within the application folder, if it is placed in bin folder, on click of Button, undefined message is displayed

Now I tried placing Webbrowser Control similar way onto the Webform, but nothing is happening. No mesage os also getting displayed. What can be the reason

Is there any other approach is there to read the external URL source through ASP.Net Webfrom

Thanks
EJ


HI Steven


创建用户控件时,在其中放置一个AxWebbrowser控件并将其放置webform内的usercontrol并没有显示执行控件本身。如果任何其他控件放在用户控件中并尝试没有问题一切正常。


这是什么解决方案?或者是否有其他方式来阅读外部URL的源代码我们正在导航到


请帮助我们。


谢谢

Vani
HI Steven

When a usercontrol is created placing a AxWebbrowser Control in it and placed this usercontrol inside webform and executed the control itself is not getting displayed. If any other controls are placed in user control and tried there is no problem everything works fine.

What is the solution for this? Or Is there any other way to read source code of external URL we are navigating to

Please help us.

Thanks
Vani


这篇关于在ASP.NET Web表单中触发单击事件和读取外部URL的IFrame源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆