I have virtually no experience with web development but now I need to create a web part for SharePoint 2010 and I am stuck.
The web part is supposed to find all content types derived from folder content type and create buttons that would open the upload form for that content type. This means that the buttons must be generated dynamically depending on the content types of each library.
I've managed to create my web part but I can't get it to display the form correctly. If i simply say that each button is a hyperlink, the form is opened in a new window and doesn't close when I am done with the form. To get to open in a popup like a normal upload form I use the following code:
button.OnClientClick = "javascript:" +
" var options = {" +
" url: '" + Url + "'," +
" title: 'Create Folder'," +
" allowMaximize: true," +
" showClose: true," +
" width: 800," +
" height: 600" +
" };" +
"SP.UI.ModalDialog.showModalDialog(options);";
What I am doing is assigning a JavaScript code to a previously defined LinkButton in my .cs file. In fact all of my code is in the .cs file.
What happens when this is run is that the form opens and I am able to create a new folder. When I close it however, the popup doesn't close. Instead I am left with a blank popup that can't be closed even when clicking the X in the upper right hand corner. I have to reload the page to get the form popup to go away.
So how do I close this form or open it in such a way that I don't run into problems. If the solution is to combine C# with some client side code please be very specific because I have no clue how this is done.