There comes a situation when you want the default Ok or Edit item or close buttons in SharePoint forms pages like Newform.aspx, Dispform.aspx and Editform.aspx to redirect user to new page then specified. To do that we can use java script code to redirect users to different page then the normal ones. I am using an instant of giving an alert to user when user clicks on Ok button of editform.aspx . I am using content editor webpart to add javascript code to editform.aspx page. You can look into by earlier post if you are not aware of method to put content editor webpart in editform.aspx page. Here is the post click here After the Webpart is added, make sure the Inside Layout Tab, the Hidden checkmark is checked, to hide the webpart during normal use. In the content editor webpart , put this javascript code: Replace [] with < >[script language="javascript" type="text/javascript"] _spBodyOnLoadFunctionNames.push("StartUpCustomScript"); function StartUpCustomScript() { ChangeOkButtonOnclickEvent("Input","SaveItem"); } function ChangeOkButtonOnclickEvent(tagName, identifier) { var len = identifier.length; var tags = document.getElementsByTagName(tagName); /*find all Input type controls on page (ie. control with tag [Input/])*/ for (var i=0; i < tags.length; i++) { var tempString = tags[i].name; if(tempString.indexOf(identifier) == tempString.length-len ) /*find any Input type controls on page has its name ending with 'SaveItem'*/ { /*if found, replace it default onclick with our custom script*/ var func = tags[i].attributes["onclick"].value.replace("if (!PreSaveItem())","alert('you have clicked OK');if (!PreSaveItem())"); /*remove its default onclick event*/ tags[i].onclick = null; /*re-register its onlick event with new script*/ tags[i].attachEvent("onclick",new Function(func)); } } return null; } [/script]
Adding this now as soon as from editform.aspx when you click Ok button , a alert message will pop up.Job done :)
Tips on Microsoft Dynamic CRM, Crystal Reports, Ensemble Cache, Microsoft SharePoint and more
Thursday, October 2, 2008
Add New Event to Buttons of default Newform.aspx, Dispform.aspx and Editform.aspx
Subscribe to:
Post Comments (Atom)
RootComponent types in solution.xml file in Dynamics CRM 365/2016
In Microsoft Dynamic CRM 2016/365 are you as confused as me when looking at the solution.xml from the solution export? looking at the xml a...
-
In Microsoft Dynamic CRM 2016/365 are you as confused as me when looking at the solution.xml from the solution export? looking at the xml a...
-
Crystal report works great when the export feature is used to export reports to PDF and word, but the one real drawback is the ‘Export to ...
-
1. Stop: Stop: Play. Skip advertisements in movies and go straight to the movie. 2. Dial 0 during most automatic menu phone systems to b...
No comments:
Post a Comment