We are using UserControl editForm to insert/update records. We need to perform some client side validations .
So we have included a onclick attribute and associate a javascript function for the Update button inside the usercontrol.The Client side Onclick event is getting fired only on the parent page and not on the user control. so we placed the client side function on the parent page and upon returning true the pgae is not getting submitted.
Is something we are missing.Any help on this would be greatly apprecaiated.
Please find below the client sid ecode in the parent page
function
OnUpdateClick()
{
var hasActiveChild = document.getElementById("<%=hdnHasActiveChild.ClientID%>").value;
var confirmMsg = 'There are active children which would also become inactive, Do you want to continue?';
var hasConsolidation = document.getElementById("<%=hdnHasConsolidation.ClientID%>").value;
var allowPostBsckforActive = '';
var allowPostBsckforConsolidation = '';
if(hasActiveChild =='Yes' && isActiveChecked =='No')
{
var result = confirm(confirmMsg);
if(result)
{
document.getElementById(
"<%=hdnDeActiveChildProducts.ClientID%>").value = 'Yes';
allowPostBsckforActive =
'Yes';
}
else
{
document.getElementById(
"<%=hdnDeActiveChildProducts.ClientID%>").value = 'No';
allowPostBsckforActive =
'No';
}
}
//
if(hasConsolidation == 'Yes')
{
var result = confirm('The selected consolidation will be deleted, do you want to proceed?');
if(result)
{
document.getElementById(
"<%=hdnDeleteConsolidation.ClientID%>").value = 'Yes';
allowPostBsckforConsolidation =
'Yes';
}
else
{
document.getElementById(
"<%=hdnDeleteConsolidation.ClientID%>").value = 'No';
allowPostBsckforConsolidation =
'No';
}
}
if((allowPostBsckforConsolidation == 'Yes' && (allowPostBsckforActive=='' || allowPostBsckforActive=='No')) || (allowPostBsckforActive == 'Yes' && (allowPostBsckforConsolidation=='' || allowPostBsckforConsolidation=='No') ))
{
alert(
'true');
return true;
_doPostback();
}
else
{
alert(
'false');
return false;
}
}
Thanks and Regards
V.Balamurali