By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,285 Members | 2,232 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,285 IT Pros & Developers. It's quick & easy.

Find Window from Client-Side (ActiveX?) to Copy Contents into Web

P: n/a
Hello,

I'm running an asp.net, intranet web application using .net framework 1.1 on
IIS5.1 / 6.0. Through the web application, I would like to press a button on
the web page, have another window (not web-based or part of current
application) brought to the front and focused (findwindow api) and have the
button scrape the contents of the focused window so the contents can be
parsed and entered into the web application.

Ideally, I would like to do this server-side, but I don't think I can get to
a window on the client's pc to bring it to the front. I'm definitely open to
javascript since this is an intranet application and the environment is
controlled.

I've considered and attempted to create an ActiveX control that will be in a
web page (object tag). The class library project contains an interface,
IScreenScrape, that defines the method and properties available (COM
support?). If I run the ActiveX control and exit before it attempts to
"activate" the other application's window, the properties are accessible and
contain values, and the process finishes successfully. The ActiveX control
seems to work until it attempts to "activate" the other application's window
where I get a System.Security.Permissions.SecurityPermission error. This
action is initiated through Javascript by calling
USSActiveX.GetVisionInformation().

Things I've tried:
1) I've added my local pc to the "Trusted Sites" in IE 7;
2) I've modified code-access security in LocalIntranet_Zone to FullTrust and
Everything;
3) I've strong-name signed the dll that houses the ActiveX control (when I
did this, I started getting a Javascript error indicating "object does not
support this property or method" even though it exists).

Any help that can be provided is appreciated. Thanks.

Web Application calling code:

<%@ Page language="c#" Codebehind="WebForm4.aspx.cs" AutoEventWireup="false"
Inherits="Test_ActiveXDotNetWeb.WebForm4" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm4</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
<script type="text/javascript">
function doScript()
{
USSActiveX.GetVisionInformation();
Form1.hdnName.value = USSActiveX.ApplicantName;
Form1.hdnSSN.value = USSActiveX.ApplicantSSN;
Form1.hdnOTA.value = USSActiveX.OrgTypeApplicationNumber;
Form1.hdnScreen.value = USSActiveX.VisionScreen;

}
</script>
</HEAD>
<body>
<OBJECT id="USSActiveX"
classid="Unicorn.ScreenScrapeActiveX.dll#Unicorn.S creenScrapeActiveX.ScreenScrape"
name="USSActiveX" VIEWASTEXT>
</OBJECT>
<form id="Form1" method="post" runat="server">
<input type="hidden" id="hdnName" runat="server" NAME="hdnName"<input
type="hidden" id="hdnSSN" runat="server" NAME="hdnSSN">
<input type="hidden" id="hdnOTA" runat="server" NAME="hdnOTA"<input
type="hidden" id="hdnScreen" runat="server" name="hdnScreen">
<br>
<input type="text" name="txt" value="Enter text here">
<br>
<asp:Button ID="butSetText" Runat="server" Text="Set Text"></asp:Button>
</form>
</body>
</HTML>

The butSetText onclick event is assigned server side using:
this.butSetText.Attributes.Add("onclick","doScript ();");
May 15 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a
You really mean you have a managed user control, that's sthe only reason you
could get a security error. You simply need to update your cas policy with
the appropriate permissions.
--
Regards,
Alvin Bruney
------------------------------------------------------
Shameless author plug
Excel Services for .NET is coming...
OWC Black book on Amazon and
www.lulu.com/owc
Professional VSTO 2005 - Wrox/Wiley
"Greg M" <Greg M@discussions.microsoft.comwrote in message
news:A3**********************************@microsof t.com...
Hello,

I'm running an asp.net, intranet web application using .net framework 1.1
on
IIS5.1 / 6.0. Through the web application, I would like to press a button
on
the web page, have another window (not web-based or part of current
application) brought to the front and focused (findwindow api) and have
the
button scrape the contents of the focused window so the contents can be
parsed and entered into the web application.

Ideally, I would like to do this server-side, but I don't think I can get
to
a window on the client's pc to bring it to the front. I'm definitely open
to
javascript since this is an intranet application and the environment is
controlled.

I've considered and attempted to create an ActiveX control that will be in
a
web page (object tag). The class library project contains an interface,
IScreenScrape, that defines the method and properties available (COM
support?). If I run the ActiveX control and exit before it attempts to
"activate" the other application's window, the properties are accessible
and
contain values, and the process finishes successfully. The ActiveX control
seems to work until it attempts to "activate" the other application's
window
where I get a System.Security.Permissions.SecurityPermission error. This
action is initiated through Javascript by calling
USSActiveX.GetVisionInformation().

Things I've tried:
1) I've added my local pc to the "Trusted Sites" in IE 7;
2) I've modified code-access security in LocalIntranet_Zone to FullTrust
and
Everything;
3) I've strong-name signed the dll that houses the ActiveX control (when I
did this, I started getting a Javascript error indicating "object does not
support this property or method" even though it exists).

Any help that can be provided is appreciated. Thanks.

Web Application calling code:

<%@ Page language="c#" Codebehind="WebForm4.aspx.cs"
AutoEventWireup="false"
Inherits="Test_ActiveXDotNetWeb.WebForm4" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm4</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
<script type="text/javascript">
function doScript()
{
USSActiveX.GetVisionInformation();
Form1.hdnName.value = USSActiveX.ApplicantName;
Form1.hdnSSN.value = USSActiveX.ApplicantSSN;
Form1.hdnOTA.value = USSActiveX.OrgTypeApplicationNumber;
Form1.hdnScreen.value = USSActiveX.VisionScreen;

}
</script>
</HEAD>
<body>
<OBJECT id="USSActiveX"
classid="Unicorn.ScreenScrapeActiveX.dll#Unicorn.S creenScrapeActiveX.ScreenScrape"
name="USSActiveX" VIEWASTEXT>
</OBJECT>
<form id="Form1" method="post" runat="server">
<input type="hidden" id="hdnName" runat="server" NAME="hdnName"<input
type="hidden" id="hdnSSN" runat="server" NAME="hdnSSN">
<input type="hidden" id="hdnOTA" runat="server" NAME="hdnOTA"<input
type="hidden" id="hdnScreen" runat="server" name="hdnScreen">
<br>
<input type="text" name="txt" value="Enter text here">
<br>
<asp:Button ID="butSetText" Runat="server" Text="Set Text"></asp:Button>
</form>
</body>
</HTML>

The butSetText onclick event is assigned server side using:
this.butSetText.Attributes.Add("onclick","doScript ();");

May 16 '07 #2

P: n/a
Thanks for your response Alvin.

What permissions do I give it? I tried SecurityPermission to no avail. I
tried to give the LocalIntranet_Zone both FullTrust and Everything and that
didn't work. Is there some sort of Win32Permission to give the assembly?

The code I'm working with is in a Class Library DLL, not a UserControl. Do I
need to move it into a UserControl? I don't intend for any user interface
components to be on the web page (at least not visible)... I just want to be
able to have the user push a button which will then instantiate the ActiveX
to scrape data from another window for use in the web app.

Thanks.
Greg

"Alvin Bruney [MVP]" wrote:
You really mean you have a managed user control, that's sthe only reason you
could get a security error. You simply need to update your cas policy with
the appropriate permissions.
--
Regards,
Alvin Bruney
------------------------------------------------------
Shameless author plug
Excel Services for .NET is coming...
OWC Black book on Amazon and
www.lulu.com/owc
Professional VSTO 2005 - Wrox/Wiley
"Greg M" <Greg M@discussions.microsoft.comwrote in message
news:A3**********************************@microsof t.com...
Hello,

I'm running an asp.net, intranet web application using .net framework 1.1
on
IIS5.1 / 6.0. Through the web application, I would like to press a button
on
the web page, have another window (not web-based or part of current
application) brought to the front and focused (findwindow api) and have
the
button scrape the contents of the focused window so the contents can be
parsed and entered into the web application.

Ideally, I would like to do this server-side, but I don't think I can get
to
a window on the client's pc to bring it to the front. I'm definitely open
to
javascript since this is an intranet application and the environment is
controlled.

I've considered and attempted to create an ActiveX control that will be in
a
web page (object tag). The class library project contains an interface,
IScreenScrape, that defines the method and properties available (COM
support?). If I run the ActiveX control and exit before it attempts to
"activate" the other application's window, the properties are accessible
and
contain values, and the process finishes successfully. The ActiveX control
seems to work until it attempts to "activate" the other application's
window
where I get a System.Security.Permissions.SecurityPermission error. This
action is initiated through Javascript by calling
USSActiveX.GetVisionInformation().

Things I've tried:
1) I've added my local pc to the "Trusted Sites" in IE 7;
2) I've modified code-access security in LocalIntranet_Zone to FullTrust
and
Everything;
3) I've strong-name signed the dll that houses the ActiveX control (when I
did this, I started getting a Javascript error indicating "object does not
support this property or method" even though it exists).

Any help that can be provided is appreciated. Thanks.

Web Application calling code:

<%@ Page language="c#" Codebehind="WebForm4.aspx.cs"
AutoEventWireup="false"
Inherits="Test_ActiveXDotNetWeb.WebForm4" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm4</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
<script type="text/javascript">
function doScript()
{
USSActiveX.GetVisionInformation();
Form1.hdnName.value = USSActiveX.ApplicantName;
Form1.hdnSSN.value = USSActiveX.ApplicantSSN;
Form1.hdnOTA.value = USSActiveX.OrgTypeApplicationNumber;
Form1.hdnScreen.value = USSActiveX.VisionScreen;

}
</script>
</HEAD>
<body>
<OBJECT id="USSActiveX"
classid="Unicorn.ScreenScrapeActiveX.dll#Unicorn.S creenScrapeActiveX.ScreenScrape"
name="USSActiveX" VIEWASTEXT>
</OBJECT>
<form id="Form1" method="post" runat="server">
<input type="hidden" id="hdnName" runat="server" NAME="hdnName"<input
type="hidden" id="hdnSSN" runat="server" NAME="hdnSSN">
<input type="hidden" id="hdnOTA" runat="server" NAME="hdnOTA"<input
type="hidden" id="hdnScreen" runat="server" name="hdnScreen">
<br>
<input type="text" name="txt" value="Enter text here">
<br>
<asp:Button ID="butSetText" Runat="server" Text="Set Text"></asp:Button>
</form>
</body>
</HTML>

The butSetText onclick event is assigned server side using:
this.butSetText.Attributes.Add("onclick","doScript ();");


May 16 '07 #3

P: n/a
Use the .net configuration console application (mscorcfg.msc at a Visual
Studio command prompt). Right click on the evaluate assembly node found in
my computer node. Find your dll. It tells you where the application will be
run from and what permissions it needs.

Actually there is a better, simpler way. Run the application and wait for it
to choke. Open your browser, and find the temporary file. Look for a
fusionlog file in the list of temporary file. Open that file in notepad by
dragging it into notepad. That file is a stack dump of the permissions
error. The stack dump tells you which permission is missing. Add that
permission to your cas policy (1st paragraph). Reset IIS you should be all
set. I have an article about this on MSDN but i forget where it is. google
if you feel lucky.

--
Regards,
Alvin Bruney
------------------------------------------------------
Shameless author plug
Excel Services for .NET is coming...
https://www.microsoft.com/MSPress/books/10933.aspx
OWC Black Book www.lulu.com/owc
Professional VSTO 2005 - Wrox/Wiley
"Greg M" <Gr***@discussions.microsoft.comwrote in message
news:DA**********************************@microsof t.com...
Thanks for your response Alvin.

What permissions do I give it? I tried SecurityPermission to no avail. I
tried to give the LocalIntranet_Zone both FullTrust and Everything and
that
didn't work. Is there some sort of Win32Permission to give the assembly?

The code I'm working with is in a Class Library DLL, not a UserControl. Do
I
need to move it into a UserControl? I don't intend for any user interface
components to be on the web page (at least not visible)... I just want to
be
able to have the user push a button which will then instantiate the
ActiveX
to scrape data from another window for use in the web app.

Thanks.
Greg

"Alvin Bruney [MVP]" wrote:
>You really mean you have a managed user control, that's sthe only reason
you
could get a security error. You simply need to update your cas policy
with
the appropriate permissions.
--
Regards,
Alvin Bruney
------------------------------------------------------
Shameless author plug
Excel Services for .NET is coming...
OWC Black book on Amazon and
www.lulu.com/owc
Professional VSTO 2005 - Wrox/Wiley
"Greg M" <Greg M@discussions.microsoft.comwrote in message
news:A3**********************************@microso ft.com...
Hello,

I'm running an asp.net, intranet web application using .net framework
1.1
on
IIS5.1 / 6.0. Through the web application, I would like to press a
button
on
the web page, have another window (not web-based or part of current
application) brought to the front and focused (findwindow api) and have
the
button scrape the contents of the focused window so the contents can be
parsed and entered into the web application.

Ideally, I would like to do this server-side, but I don't think I can
get
to
a window on the client's pc to bring it to the front. I'm definitely
open
to
javascript since this is an intranet application and the environment is
controlled.

I've considered and attempted to create an ActiveX control that will be
in
a
web page (object tag). The class library project contains an interface,
IScreenScrape, that defines the method and properties available (COM
support?). If I run the ActiveX control and exit before it attempts to
"activate" the other application's window, the properties are
accessible
and
contain values, and the process finishes successfully. The ActiveX
control
seems to work until it attempts to "activate" the other application's
window
where I get a System.Security.Permissions.SecurityPermission error.
This
action is initiated through Javascript by calling
USSActiveX.GetVisionInformation().

Things I've tried:
1) I've added my local pc to the "Trusted Sites" in IE 7;
2) I've modified code-access security in LocalIntranet_Zone to
FullTrust
and
Everything;
3) I've strong-name signed the dll that houses the ActiveX control
(when I
did this, I started getting a Javascript error indicating "object does
not
support this property or method" even though it exists).

Any help that can be provided is appreciated. Thanks.

Web Application calling code:

<%@ Page language="c#" Codebehind="WebForm4.aspx.cs"
AutoEventWireup="false"
Inherits="Test_ActiveXDotNetWeb.WebForm4" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm4</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
<script type="text/javascript">
function doScript()
{
USSActiveX.GetVisionInformation();
Form1.hdnName.value = USSActiveX.ApplicantName;
Form1.hdnSSN.value = USSActiveX.ApplicantSSN;
Form1.hdnOTA.value = USSActiveX.OrgTypeApplicationNumber;
Form1.hdnScreen.value = USSActiveX.VisionScreen;

}
</script>
</HEAD>
<body>
<OBJECT id="USSActiveX"
classid="Unicorn.ScreenScrapeActiveX.dll#Unicorn.S creenScrapeActiveX.ScreenScrape"
name="USSActiveX" VIEWASTEXT>
</OBJECT>
<form id="Form1" method="post" runat="server">
<input type="hidden" id="hdnName" runat="server" NAME="hdnName"<input
type="hidden" id="hdnSSN" runat="server" NAME="hdnSSN">
<input type="hidden" id="hdnOTA" runat="server" NAME="hdnOTA"<input
type="hidden" id="hdnScreen" runat="server" name="hdnScreen">
<br>
<input type="text" name="txt" value="Enter text here">
<br>
<asp:Button ID="butSetText" Runat="server" Text="Set
Text"></asp:Button>
</form>
</body>
</HTML>

The butSetText onclick event is assigned server side using:
this.butSetText.Attributes.Add("onclick","doScript ();");



May 17 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.