nvs_victor
asked on
Yes / No Confirmation Box for ASP.NET Web Pages?
Yes / No Confirmation Box for ASP.NET Web Pages?
Hi Experts,
I’ve been spending a few hours looking for a Javascript equivalent of a Yes / No confirmation box solution (much like the link below), to no avail.
http://www.w3schools.com/j s/tryit.as p?filename =tryjs_con firm
Apparently, most of the solutions I’ve found only works in Web Forms. Some of them utilize a postback solution, which isn’t for Web Pages.
So I was wondering if there was a quick and easy Web Pages solution?
Thanks!
Hi Experts,
I’ve been spending a few hours looking for a Javascript equivalent of a Yes / No confirmation box solution (much like the link below), to no avail.
http://www.w3schools.com/j
Apparently, most of the solutions I’ve found only works in Web Forms. Some of them utilize a postback solution, which isn’t for Web Pages.
So I was wondering if there was a quick and easy Web Pages solution?
Thanks!
Here is some sample code that demonstrates the principle
<!doctype html>
<html>
<head>
<title>Test</title>
<script src="http://code.jquery.com/jquery.js"></script>
<script type="text/javascript">
$(function() {
// Catch the open click
$('a.popup').click(function(e){
// prevent <a> from doing its usual thing and browsing away from page.
e.preventDefault();
// What popup do we want to show (can support more than one this way)
var id = $(this).attr('href');
// Work out where to put it - left is half the width of the doc less half the width of the popup
var left = ($(document).width() - $(id).width()) >> 1;
// Same with top - use the >> to divide by 2 because old school
var top = ($(document).height() - $(id).height()) >> 1;
// create a clone of our template, show it set the metrics to position it add a class to show it is on screen and remove the id so we don't have dupes
var popup = $(id).clone().show().css({left: left + 'px', top: top + 'px'}).addClass('popped').attr('id','');
// create an overlay to make our popup modal
var overlay = $('<div/>').addClass('overlay').css({height: $(document).height() + 'px'});
// finally add to the body
$('body').prepend(overlay).append(popup);
});
// Dynamic click handler for close button - remove the layers we created in open
$('body').on('click','.close', function(e) {
e.preventDefault();
$('.overlay').remove();
$('.popped').remove();
});
});
</script>
<style type="text/css">
.overlay {
position: absolute;
left: 0;
top: 0;
background: #000;
opacity: .95;
z-index: 1;
width: 100%;
}
.popup-box {
position: absolute;
z-index: 100;
display: none;
}
#popup {
width: 300px;
height: 150px;
border: 2px solid #ef092a;
background: #fff;
}
</style>
</head>
<body>
<a href="#popup" class="popup">Click to open popup</a>
<div id="popup" class="popup-box" >
Put what you want in here
<a href="#" class="close">This link closes the popup</a>
</div>
</body>
</html>
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi mathew_s and julianH,
thank you for helping!
Unfortunately, this won't help... Javascript is client-side... ASP.NET is server side. If I were to use Javascript to capture the what the user pressed, I'll need to capture the input and send it to ASP to process it. Javascript cannot help.
If I'm not mistaken, this is the process:
HTML Request --> Server --> ASP Processing --> create HTML page with Javascript inside --> Sends HTML page to original requester.
As you can see, Javascript is at the end of the processing list... it's one direction only. Sure, I can prompt the user with Javascript, but Javascript cannot tell ASP what button the client pressed.
The only solution with Javascript is if I send the input back to the server, but that's complicated.
thank you for helping!
Unfortunately, this won't help... Javascript is client-side... ASP.NET is server side. If I were to use Javascript to capture the what the user pressed, I'll need to capture the input and send it to ASP to process it. Javascript cannot help.
If I'm not mistaken, this is the process:
HTML Request --> Server --> ASP Processing --> create HTML page with Javascript inside --> Sends HTML page to original requester.
As you can see, Javascript is at the end of the processing list... it's one direction only. Sure, I can prompt the user with Javascript, but Javascript cannot tell ASP what button the client pressed.
The only solution with Javascript is if I send the input back to the server, but that's complicated.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You are welcome - thanks for the points.
ASKER
Experts helped me think of a workable solution using javascript.
http://dev.sencha.com/depl
Check this link out that uses the library.
http://dev.sencha.com/depl
The first is yes/no javascript dialog using the library.