I have 2 different client webpart, A and B

client webpart A at page 1 and client webpart B at page 2..

client webpart A have action to redirect host page to page 2 (which is client webpart B), with certain url parameter that client webpart B needed..

Is there any solution of better alternative ?

note : for visual webpart it gonna be easy, but since client webpart use iframe, I still haven't get any clue to do this..

Update :

Ok, redirect host page from iframe is pretty simple https://stackoverflow.com/questions/2092275/redirect-the-parent-page-from-iframe

But I still didn't now to get URL parameter from client webpart host URL

Update #2 :

from here http://social.msdn.microsoft.com/Forums/en-US/956d92fb-e0b3-4f32-9dae-c5ba5948949b/get-host-page-url-in-app-part, i learn that it is impossible to get host URL from client webpart.

but is it possible when first rendering of iframe, parent URL also pass its parameter to client webpart, like Facebook app : https://stackoverflow.com/questions/3175300/facebook-iframe-application-how-to-pass-data-from-url-query-string


So if I understand your question you need to pass querystring parameters from the parent page down to an iframe (hosted webpart), correct?

I wrote something that does this in a bit of a specific way, but ultimately you follow this logic:

  1. On the parent page, use javascript to find the iframe dom object and get it's "src" attribute
  2. Grab the querystring off the parent page url
  3. Update the src attribute of the iframe to include your parent page's querystring param(s)

HOWEVER, in the case of sharepoint, the url on the iframe is actually a sharepoint redirect url that contains a "redirect_uri" to your hosted app's url. This means you don't add the querystring direct to the end of the "src" url (with a simple &param1=...), but instead you parse the redirect_uri off the src and decode it, then add the encoded qs param to that, then re-encode it and set the new "decoded/encoded/re-encoded" value as the src for the iframe.

Yes, it can get messy with encoding/decoding, especially if your querystring param also requires encoding, but it is possible, I've done it.


Go through this article which may help you How to: Pass parameters to a Client Web Part

  • 3
    Please add more details to your answer, if the link breaks it will be of little help to future readers as it's written now. – Nadeem Yousuf-AIS Jan 6 '14 at 6:11
  • i dont think that post is for parameter from url, "that parameters are equivalent to the properties on traditional web parts" – adhitya febrian Jan 6 '14 at 10:47
  • The link is broken. – David Arno Jul 10 '20 at 16:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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