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'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?

share|improve this question

2 Answers 2

up vote 5 down vote accepted

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');">
share|improve this answer
    
+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. –  Abe Miessler Apr 13 '11 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 - SharePoint MVP Apr 13 '11 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 - SharePoint MVP Apr 13 '11 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? –  Abe Miessler Apr 13 '11 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 –  Abe Miessler Apr 13 '11 at 14:31

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>
share|improve this answer
    
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. –  Abe Miessler Apr 13 '11 at 6:23

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.