Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I made some custom list definitions in Visual Studio 2010 and deploy them to SharePoint 2010. I also made a Visual Web Part with a form. With this form I'm able to feed multiple of my lists with just that one form (it's done with a loop in C#). For now, the Visual Web Part with that form is opened in a Modal Dialog with the help of a custom button in the lists Ribbon-Menu (CustomAction).

But I would also like to open the form by clicking on the default "Add new item" link which is positioned under each list. I think it would be enough to change the "onclick"-method to the function which is already on the button in the Ribbon-Menu. But how can I change the "onclick"-method? Or do you know any other solution?

Thank you in advance for your help!

share|improve this question
1  
I just figured it out how to do it: in the SharePoint list, I went to "Default New Form" and added my web part. To not get an error message, the default web part with the default form must be "Closed", and not deleted. Anyway: if someone knows how to do that programmatically, it would be great. Thank you, Mike –  Mike Jun 8 '12 at 11:56

2 Answers 2

Mike, For future reference, it is always better to save your default newForm.aspx as something else like NewFormOne.aspx and then modify that one and set as your default form. You can just hide the default webpart and add your custom below it. That way it will stay in your forms list within SPDesigner allowing it to be set as default. Else you would need to accomplish setting it as default through Studio. (pain)

share|improve this answer

A simplistic way to do it would be to figure out how to select that button, be it it's ID or CSS and use jQuery (or javascript) to set the on click. $('#NEwItemButtonsID').click(function(){ doOpen(); return false}); return false; stops the post back.

There might be a way to do it with manged code, but I am not sure.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.