Answered by:
Dynamically Loading the App inside the Client Web parts

Question
-
Hi,
We have around 20 ASP.Net applications that are residing in different web server.We are in the process of creating the High Trust Provider hosted app for each aplication.
Currenty we are creating client web part for each apps which is tedious to create 20 Client Web parts for 20 applications.
The below url in the Client Web part Elements.xml file is the sample one for our Provider Hosted app web.
Content Src="~remoteAppUrl/Pages/Default.aspx?{StandardTokens}" Type="html"/>
Is there a way to create a single Client Web part and dynamically load the url for the Provider Hosted App web which is invoked.We want to provide the Src attribute dynamically instead of creating Client Web part for each and every applications.
Please let me know your thoughts.
Thanks, Vijay Arul Lourdu
Thursday, December 6, 2012 7:26 AM
Answers
-
Hey Vijay,
Sorry for the delay. A quick solution came to my mind is that your client web part page will read the appurl property and redirect itself to corresponding provider hosted app URL. If you have a custom property (appurl) defined for your client web part, here is what you can do to configure it dynamically:
- Insert your client web part to a web part page or wiki page.
- Put the page in edit mode.
- Edit the client web part (Hover mouse to the web part chrome and from the dropdown menu)
- In the web part property panel, custom section, you should see "appurl" property there.
Instead of using a string for your custom web part property, you can use enum so it will be easier for users to choose the right app.
Take a loot at this article for how to use client web part and custom properties. http://msdn.microsoft.com/en-us/library/fp179921(v=office.15).aspx
Here is another example of how to use client web part: http://code.msdn.microsoft.com/SharePoint-2013-App-part-9d83703c
Thanks,
Gary- Edited by Gary C.W. ChangMicrosoft employee Wednesday, December 12, 2012 10:27 PM
- Proposed as answer by Humberto LezamaMicrosoft employee Wednesday, December 12, 2012 10:54 PM
- Marked as answer by Christopher Clement Friday, January 4, 2013 5:31 PM
Wednesday, December 12, 2012 10:26 PM
All replies
-
Hello Vijay,
Maybe you can leverage the custom properties for the client web part. So you add the client web part to a page, configure the custom web part property with some string like "App1". The client web part page you created will take this property string and then redirect to App1 page. Does this make sense to you?
Thanks,
GaryThursday, December 6, 2012 7:49 PM -
Gary,
Thanks for the prompt response.We are plannning to have a single Client Web part which will be added to a single page.
If we have the custom property named Appurl string property(Which will have appurl) how will we set the apurl property dynamically based on the title of the Provider Hosted App which is invoked.
Please advice.
Thanks, Vijay Arul Lourdu
Friday, December 7, 2012 5:59 AM -
Hey Vijay,
Sorry for the delay. A quick solution came to my mind is that your client web part page will read the appurl property and redirect itself to corresponding provider hosted app URL. If you have a custom property (appurl) defined for your client web part, here is what you can do to configure it dynamically:
- Insert your client web part to a web part page or wiki page.
- Put the page in edit mode.
- Edit the client web part (Hover mouse to the web part chrome and from the dropdown menu)
- In the web part property panel, custom section, you should see "appurl" property there.
Instead of using a string for your custom web part property, you can use enum so it will be easier for users to choose the right app.
Take a loot at this article for how to use client web part and custom properties. http://msdn.microsoft.com/en-us/library/fp179921(v=office.15).aspx
Here is another example of how to use client web part: http://code.msdn.microsoft.com/SharePoint-2013-App-part-9d83703c
Thanks,
Gary- Edited by Gary C.W. ChangMicrosoft employee Wednesday, December 12, 2012 10:27 PM
- Proposed as answer by Humberto LezamaMicrosoft employee Wednesday, December 12, 2012 10:54 PM
- Marked as answer by Christopher Clement Friday, January 4, 2013 5:31 PM
Wednesday, December 12, 2012 10:26 PM -
Thanks Gary for the Blog.I will try it out and will keep you posted on the same.
Thanks, Vijay Arul Lourdu
Tuesday, December 18, 2012 1:29 AM -
Gary,
Thanks for the prompt response.We are plannning to have a single Client Web part which will be added to a single page.
If we have the custom property named Appurl string property(Which will have appurl) how will we set the apurl property dynamically based on the title of the Provider Hosted App which is invoked.
Please advice.
Thanks, Vijay Arul Lourdu
I have a similar requirement to Vijay's in which I install a High-Trust provider-hosted app in different sharepoint sites and render the app as App part using Client Web Part(Host Web). I know I can pass parameters to the app through custom properties. Is there a way to render values to the custom properties dynamically without having the user edit the app part.
I have the values as query strings of content page holding app part.Thursday, May 2, 2013 10:37 PM