Jquery popup and postback button in sharepoint
on hyperlink click i have to popup a div tag and in popup i have button with click event with some validations.but in this scenario my button is not postbacking.
On google i found using this javascript finally am firing button click event to server side.
e.preventPropagation();
<link type="text/css" rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.js"></script>
<script type="text/javascript" src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<script type="text/javascript">
$('#Regularclick').click(function () {
var dlg = $("#popupdiv").dialog({
title: "Download Application Form",
width: 610,
height: 310,
modal: true,
buttons: {
Close: function () {
$(this).dialog('close');
}
}
});
$('#<%= txtARNCode.ClientID %>').val() = '';
$('#<%= txteuin.ClientID %>').val() = '';
$('#<%= txtbroker.ClientID %>').val() = '';
// dlg.parent().appendTo(jQuery("form:first"));
});
$('#Regularclickimg').click(function () {
var dlg = $("#popupdiv").dialog({
title: "Download Application Form",
width: 610,
height: 310,
modal: true,
buttons: {
Close: function () {
$(this).dialog('close');
}
}
});
$('#<%= txtARNCode.ClientID %>').val() = '';
$('#<%= txteuin.ClientID %>').val() = '';
$('#<%= txtbroker.ClientID %>').val() = '';
// dlg.parent().appendTo(jQuery("form:first"));
});
})
function btndownload() {
var valARN = $('#<%= txtARNCode.ClientID %>').val();
if (valARN == "ARN-") {
alert('Please Enter Distributor Code');
e.preventPropagation();
return false;
}
// var val = $('#<%= txtARNCode.ClientID %>').is(':contains("ARN-")');
if (valARN.indexOf("ARN-") != 0) {
alert('Please Enter Distributor Code as shown in example');
e.preventPropagation();
return false;
}
var valeuin = $('#<%= txteuin.ClientID %>').val();
if (valeuin == "") {
alert('Please Enter EUIN Code');
e.preventPropagation();
return false;
}
// else {
// alert('hi');
$('#<%= hdnARNCode.ClientID %>').val(valARN);
var valbroker = $('#<%= txtbroker.ClientID %>').val();
$('#<%= hdntxtbroker.ClientID %>').val(valbroker);
$('#<%= hdntxteuin.ClientID %>').val(valeuin);
// __doPostBack('<%= btnDownload.ClientID %>', 'OnClick');
//return true;
// }
//return;
}
function validate(key) {
//getting key code of pressed key
var keycode = (key.which) ? key.which : key.keyCode;
var phn = document.getElementById('txteuin');
//comparing pressed keycodes
if (!(keycode == 8 || keycode == 46) && (keycode < 48 || keycode > 57)) {
return false;
}
else {
//Condition to check textbox contains ten numbers or not
if (phn.value.length < 6) {
return true;
}
else {
return false;
}
}
}
</script>
<style>
.tdhead2 {
background-color:#4CC1D1;
color: #000;
font-weight: bold;
font-size: 12px;
text-align: center;
}
.dwntd {
border-bottom: 1px solid #CCC;
border-left: 1px solid #CCC;
border-right: 1px solid #CCC;
color: #000;
height: 25px;
padding: 3px;
}
</style>
<div>
<div id="popupdiv" title="Basic modal dialog" style="display: none;width:610px;height:310px; min-height:300px; z-index" >
On google i found using this javascript finally am firing button click event to server side.
e.preventPropagation();
<link type="text/css" rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.js"></script>
<script type="text/javascript" src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<script type="text/javascript">
$('#Regularclick').click(function () {
var dlg = $("#popupdiv").dialog({
title: "Download Application Form",
width: 610,
height: 310,
modal: true,
buttons: {
Close: function () {
$(this).dialog('close');
}
}
});
$('#<%= txtARNCode.ClientID %>').val() = '';
$('#<%= txteuin.ClientID %>').val() = '';
$('#<%= txtbroker.ClientID %>').val() = '';
// dlg.parent().appendTo(jQuery("form:first"));
});
$('#Regularclickimg').click(function () {
var dlg = $("#popupdiv").dialog({
title: "Download Application Form",
width: 610,
height: 310,
modal: true,
buttons: {
Close: function () {
$(this).dialog('close');
}
}
});
$('#<%= txtARNCode.ClientID %>').val() = '';
$('#<%= txteuin.ClientID %>').val() = '';
$('#<%= txtbroker.ClientID %>').val() = '';
// dlg.parent().appendTo(jQuery("form:first"));
});
})
function btndownload() {
var valARN = $('#<%= txtARNCode.ClientID %>').val();
if (valARN == "ARN-") {
alert('Please Enter Distributor Code');
e.preventPropagation();
return false;
}
// var val = $('#<%= txtARNCode.ClientID %>').is(':contains("ARN-")');
if (valARN.indexOf("ARN-") != 0) {
alert('Please Enter Distributor Code as shown in example');
e.preventPropagation();
return false;
}
var valeuin = $('#<%= txteuin.ClientID %>').val();
if (valeuin == "") {
alert('Please Enter EUIN Code');
e.preventPropagation();
return false;
}
// else {
// alert('hi');
$('#<%= hdnARNCode.ClientID %>').val(valARN);
var valbroker = $('#<%= txtbroker.ClientID %>').val();
$('#<%= hdntxtbroker.ClientID %>').val(valbroker);
$('#<%= hdntxteuin.ClientID %>').val(valeuin);
// __doPostBack('<%= btnDownload.ClientID %>', 'OnClick');
//return true;
// }
//return;
}
function validate(key) {
//getting key code of pressed key
var keycode = (key.which) ? key.which : key.keyCode;
var phn = document.getElementById('txteuin');
//comparing pressed keycodes
if (!(keycode == 8 || keycode == 46) && (keycode < 48 || keycode > 57)) {
return false;
}
else {
//Condition to check textbox contains ten numbers or not
if (phn.value.length < 6) {
return true;
}
else {
return false;
}
}
}
</script>
<style>
.tdhead2 {
background-color:#4CC1D1;
color: #000;
font-weight: bold;
font-size: 12px;
text-align: center;
}
.dwntd {
border-bottom: 1px solid #CCC;
border-left: 1px solid #CCC;
border-right: 1px solid #CCC;
color: #000;
height: 25px;
padding: 3px;
}
</style>
<div>
<div id="popupdiv" title="Basic modal dialog" style="display: none;width:610px;height:310px; min-height:300px; z-index" >
Comments