2

I have an requirement and I have no idea how to implement it. I have page Layout where gridview and some Textbox are there. In this page Layout I will programmatically place a new URL in a hidden field and I want to open this link in new window automatically if visit the page layout.

It doesn't need to be a hidden field any other options where I can pass the URL and open the link in new window.

Any idea how can I do this ?

Here is page layout how it looks

image

The right side PDF in the content editor webpart I want to display in a new window when the page layout is opened.

Thanks

5
  • you mean new window as tab or javascript window.open method? Aug 20, 2014 at 15:28
  • So as soon as you visit the page layout you wanna get redirected to another url? Aug 20, 2014 at 15:46
  • Add some screenshots , that shld explain for better understanding.
    – Nikhil J
    Aug 20, 2014 at 20:24
  • Actually there is a page layout where i have content editor webpart which is get the url of the pdf and get displayed. Now my requirements is to open this pdf in new browser window when i open the page layout. I have added the picture below Sep 2, 2014 at 8:22
  • hi Nikhil i have added a screenshot. Sep 2, 2014 at 12:45

3 Answers 3

2

Create a new visual webpart and place the below webpart in your page layout . instead of hidden value pass the url in query string . The code will check for the query string and redirect the page in new window.

Eg:https://abcd.com?Source=http://www.yoururlinnewwindow.com , onload of page will redirect to new page .

       SPSecurity.RunWithElevatedPrivileges(delegate()
        {

            if (Request.QueryString["Source"] != null)
            {
                string Source = Request.QueryString["Source"].ToString();
                HttpContext.Current.Response.Redirect(Source);
            }
        });
0

Use a combination of a new JavaScript section in the main place holder of the page layout and the hidden field's value.

The new page layout code might look something like this in the standard view:

<script>
var url = <SharePointWebControls:FieldValue FieldName="PopupURL" runat="server"/>;
window.open(url,'name','height=200,width=150');
</script>

To edit the PopupURL field, you probably want to make use of the PublishingWebControls:EditModePanel

1
  • 1
    Thank you Tom Resing. This javascript worked with little bit change to it. Sep 3, 2014 at 11:10
0

This Javascript worked perfectly for me. Thank you all for your support.

var url = document.getElementById("").value; window.open(url,"", 'height=500,width=500');

Your Answer

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

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