1

I'd like to have a pop up that contains an aspx page. It appears that adding an aspx page to a web part is not possible. When I went to add a new item to the project the closest I could find were ascx or htm.

In an effort to get something I tried adding the htm page, first to the project and then to the Layouts Mapped folder. Everytime I opened the popup it gave me a 404 error.

Here is the html/javascript I had when the file was in the Layouts mapped folder:

<a href="javascript:OpenPopUpPage('ProjectName/test.htm');">Show Me the Pop-Up!</a>

and here is what I had when it was in the project base:

<a href="javascript:OpenPopUpPage('test.htm');">Show Me the Pop-Up!</a>

Does it look like I have done anything wrong here? Is it possible to add an aspx to a web part? If not, is there an alternative?

2 Answers 2

5

I think your URL is also misconstructed. If your ASPX sits in the layouts folder you should add the path to that page including _layouts.

<a href="javascript:SP.UI.ModalDialog.OpenPopUpPage('/_layouts/mypage.aspx');">
6
  • +1, awesome. That worked for the html page, no more 404 error! Do you know if it's possible to add a aspx to my web part or should I just try with an ascx or something? I definitely need the pop up to have ASP.NET functionality. Commented Apr 13, 2011 at 6:25
  • 1
    The popup expects a page like an ASPX or HTML file. ASCX files cannot be opened directly from the client due to it being a control and not a page. ASP.NET actively blocks requests for ASCX files coming from the client.
    – Wouter
    Commented Apr 13, 2011 at 9:05
  • Also note that 'add a aspx to a webpart' is something that is not possible. A web part is an ASP.NET Control, a page is, well, a page. The two have little in common. You can add a page to your project and then have your webpart render a link to that page, for instance using that script.
    – Wouter
    Commented Apr 13, 2011 at 9:07
  • Hmmm, all components and functionality need to be contained in a single WSP file. Is there a way for me to do that if I need to have a WSP? Commented Apr 13, 2011 at 14:30
  • Actually I was able to add an "Application Page" which is an aspx page. I'll keep you posted on how well that works for my needs Commented Apr 13, 2011 at 14:31
1

I think you are missing the js namespaces

Try replacing the call with SP.UI.ModalDialog.OpenPopUpPage()

<a href="javascript:SP.UI.ModalDialog.OpenPopUpPage('yoururl');">Show Me the Pop-Up!</a>
1
  • No that didn't work. Just to be clear, I am getting the SharePoint style pop up. It just has a 404 error inside the pop up. Commented Apr 13, 2011 at 6:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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