Hi Steve,
You asked if there is a more direct way to launch your EXE. Curt's reply is
your answer. I'd like to expand on that answer.
You currently use an <a> tag to run javascript code to open a new window.
You could instead set the <a> tag's HREF to the EXE itself. Then EXE will
run on the client machine with no additional window and no javascript.
Whenever you launch an EXE in a user's browser, the browser will first
prompt the user if they want to allow the program to run. This will apply
if you launch the program in the same window or if you use window.open to
open a new window.
When using window.open, you can specify attributes for the window. Your
sample specifies 'height=350,width=350,menubar=no,status=no,toolbar=no'.
When pointing an <a> tag's HREF directly to the EXE, you cannot specify
window attributes.
* Your current method:
<a href="javascript:var newWindow=window.open('printCheckClient.exe',
1,'height=350,width=350,menubar=no,status=no,toolbar=no')">test</a>
* Pointing the <a> tag directly to the EXE:
<a href="printCheckClient.exe">test</a>
* You also asked about using a button:
<script language=javascript>
function Button1_Click() {
var newWindow=window.open('printCheckClient.exe',
1,'height=350,width=350,menubar=no,status=no,toolbar=no');
}
</script>
<INPUT type=button id="Button1" name="Button1" onclick="Button1_Click();"
value="test" />
---
Though the above button sample gets the job done, you asked about using an
ASP.NET button. This gets more complicated. I recommend using an HTML
button rather than an ASP.NET button.
First off, the ASP.NET button is really meant to submit the form. If you
add code to its onclick event, that will be executed and then the form will
be submitted. You can avoid the form submission by having your client
script function return false. For IE browsers, you can also add a line of
code to your onclick event which sets event.returnValue=false;.
Second, if your page also has ASP.NET validation controls, and the button
is set to cause validation, then it gets much more complex. The validation
controls override your onclick event with their own. You can view several
workarounds at
http://authors.aspalliance.com/kenc/faq6.aspx.
---
You might also be interested in attributes.add. This allows you to use
server-side code to add the onclick attribute to the button. This applies
to ASP.NET buttons and to HTML buttons if they are set with runat="server".
See:
Code: Setting HTML Attributes for Controls in Web Forms Pages (Visual Basic)
http://msdn.microsoft.com/library/en-us/dv_vbcode/html/vbtskcodesettinghtmla
ttributesforcontrolsinwebformspagesvisualbasic.asp
You can also use server-side code to generate the script executed by the
onclick event. See:
Page.RegisterClientScriptBlock Method
http://msdn.microsoft.com/library/en-us/cpref/html/frlrfsystemwebuipageclass
registerclientscriptblocktopic.asp
---
Does this answer your question?
Thank you, Mike
Microsoft, ASP.NET Support Professional
Microsoft highly recommends to all of our customers that they visit the
http://www.microsoft.com/protect site and perform the three straightforward
steps listed to improve your computer's security.
This posting is provided "AS IS", with no warranties, and confers no rights.
Subject: Re: ASP.NET Button and VB.NET Windows Form EXE
Date: Wed, 14 Jan 2004 14:37:55 -0600
Lines: 68
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <
[email protected]>
Newsgroups: microsoft.public.dotnet.framework.aspnet
NNTP-Posting-Host: 208.252.151.83
Path:
cpmsftngxa07.phx.gbl!cpmsftngxa06.phx.gbl!TK2MSFTNGXS01.phx.gbl!TK2MSFTNGXA0
5.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP10.phx.gbl
Xref: cpmsftngxa07.phx.gbl microsoft.public.dotnet.framework.aspnet:202228
X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
like this...
http://server/dir/file.exe
that's what I meant.
--
Curt Christianson
Owner/Lead Developer, DF-Software
www.Darkfalz.com
the
exe javascript
and directly
from