How do I detect which button was clicked on "save/open/cancel" dialog?

Q

Quinn

When users clicked a unkown mime type link such as Zip on my website, a
"Save/Open/Cancel" dialog box pops up. Is there a way to detect which button
users clicked by using ASP? actually I only what to record the "valid"
click -- when Open/Save was clicked.

Thanks ahead.

Quinn
 
C

Curt_C [MVP]

Quinn said:
When users clicked a unkown mime type link such as Zip on my website, a
"Save/Open/Cancel" dialog box pops up. Is there a way to detect which button
users clicked by using ASP? actually I only what to record the "valid"
click -- when Open/Save was clicked.

Thanks ahead.

Quinn

Look in the Request.Form collection, I believe you will get a hit on the
one that was clicked and the other two will not be in there.
 
P

Patrice

You can't. The site just streams the file to the browser. What the user does
with the file is not known by the website as there is no more server side
interaction...

Denpending on what you are after you could perhaps let a userdo 3 attemps
wihtin a quite short period before blocking the download or something
similar...

Patrice
 
A

Aaron Bertrand [SQL Server MVP]

You cannot. You can't even tell whether or not they clicked on anything at
all...
 
G

Griff

But maybe you can...?

I'm guessing here as I've not tried this, but you could try something like
this:

1 - in your form, create a hidden field <input type="hidden"
id="buttonClicked" name="buttonClicked" value="">

2 - in each button, have an onclick event to run some javascript which
passes the id/name of the button, e.g. "buttonA" <input
onclick="fnClicked(buttonA)"

3 - have a JavaScript function that selects the hidden field by ID and sets
the value of this to be the parameter received. Not that familiar with
JavaScript so the following undoubtably won't work without
editing/re-writing...

function fnClicked(IDSelected)
{
hiddenElement = document.getElementById('buttonClicked');
hiddenElement.value = IDSelected;
}

Then, when the form submits, you'll have a new input element that has the
value of the button selected.

Of course, if the punter has disabled JavaScript then it obviously won't
work.

HTH

Griff
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top