locked
Popup windows RRS feed

  • Question

  • Hey,

    I'm trying to create a simple webpart  which could be mounted on any page. It only contains a link which pops up a new browser windows which loads a custom aspx page. The custom aspx page needs the url from where the user came from.

    My question is how do I get the url from where the user came from e.g the page where he clicked on the link webpart ?

    Thanks
    Saturday, March 29, 2008 1:00 PM

Answers

All replies

  • The easiest way would be to pass it in the URL of the popup window ?referingUrl=xxxx

     

    --Vince

    http://blog.thekid.me.uk

     

    Saturday, March 29, 2008 1:48 PM
  • Hey,

    Could you plz show an example ?

    thanks
    Saturday, March 29, 2008 3:56 PM
  • Code Snippet

    using System;
    using System.Text;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
     
    namespace YourNameSpace
    {
        public class LinkWebPart : WebPart
        {
            protected override void RenderContents(HtmlTextWriter writer)
            {
                writer.Write(string.Format("<a href='_layouts/your.aspx?referer={0}' target='_blank'>Your Link Text</a>", SPContext.Current.ListItemServerRelativeUrl));
            }
        }
    }

     

     

     

    HTH, Vince

    http://blog.thekid.me.uk

    Saturday, March 29, 2008 4:27 PM
  • Hey,

    One last question Wink

    Is it possible to specify where on the screen the window pop's up or perhaps specify the size of tne new window ?

    Thanks,
    Saturday, March 29, 2008 9:52 PM
  • Have a look at...

     

    http://www.javascript-coder.com/window-popup/javascript-window-open.phtml

     

    Essentially...

     

    <a href="javascript: window.open(url, ....._">Your Link</a>

     

    --Vince

    Saturday, March 29, 2008 10:56 PM