Quantcast
Channel: SNR SharePoint Blog » SharePoint Designer
Viewing all articles
Browse latest Browse all 8

Data Validation and Redirect to page in a SharePoint New form

$
0
0

Hi !

You now that you can use a Data view to create SharePoint Forms. You choose your columns and select insert as new item and …

But there is a problem here that some validation does not work in this mode. for example DropDown or radio button required fields buttons does not validate correctly. In the other hand the good thing is that you can use your custom form action and for example commit the changes and navigate to another page.

When you use a custom web part ( Inser -> SharePoint Controls -> Custom List Form ), the good thing is that all validations work fine but you can’t redirect to another page after submitting data. The RedirectUrl property of the button also didn’t work for me. I don’t know why.

So the question is how can we have a form with complete validation and redirecting after submit ?!

I searched a lot find some solutions. I solved my problem by combining a custom form web part with a custom action button and changing in it’s code like this :

  1. You use Custom List Form and Use NewItem form. Now your validation works fine and you do not need to use custom JavaScript validations.
  2. to navigate to another page after submitting data don’t use the RedirectURL property of the form button.
  3. Insert a Form Action button in the page and change the hide property of the previous submit button to True. Now we can use the “Navigate to page” action of the new form action button. BUT it does not validate the form correctly so you should do a little change in the code. you have access to it’s java script code.
  4. the original code is like this :
    onclick=”javascript: {ddwrt:GenFireServerEvent(‘__commit’)}”
    you should change it and add this code in the middle :
    onclick=”javascript: if (!Page_ClientValidate()) return false; {ddwrt:GenFireServerEvent(‘__commit’)}”
  5. for the “navigate to page” action if it didn’t work correctly. You should also change the URL in the code like this. in my case:
    onclick=”javascript: if (!Page_ClientValidate()) return false; {ddwrt:GenFireServerEvent(‘__commit;__redirect={/en/Documents/Forms/Upload.aspx}‘)}”

now save and preview your page. I did it and everything worked like a charm. GOOD LUCK !



Viewing all articles
Browse latest Browse all 8

Trending Articles