This is a migrated thread and some comments may be shown as answers.

[Solved] UserControl EditForm Client events

3 Answers 122 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Balamurali Venkatesan
Top achievements
Rank 1
Balamurali Venkatesan asked on 30 Nov 2009, 05:38 AM
Hi,

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

3 Answers, 1 is accepted

Sort by
0
Balamurali Venkatesan
Top achievements
Rank 1
answered on 30 Nov 2009, 03:26 PM
Any updates on this please
0
Balamurali Venkatesan
Top achievements
Rank 1
answered on 02 Dec 2009, 01:03 PM
can we get any help on this question
0
Veli
Telerik team
answered on 02 Dec 2009, 01:51 PM
Hi,

If you want to place the javascript inside the user control markup, and you are using AJAX, you need to put your code inside a RadScriptBlock control, so the the script gets properly registered on page after AJAX. For more information:

RadCodeBlock and RadScriptBlock

Other than that, the code should work OK. Please also note that you call __doPostBack() after a return statement, which is never going to be executed. Besides, if you are using this script for the click event of the update button, you do not need to call __doPostBack() anyway.

Regards,
Veli
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Grid
Asked by
Balamurali Venkatesan
Top achievements
Rank 1
Answers by
Balamurali Venkatesan
Top achievements
Rank 1
Veli
Telerik team
Share this question
or