Pass Query string value from SharePoint Page to provider hosted app in SharePoint 2013

Posted: August 27, 2015 in SharePoint2013

Instruction

In the new SharePoint App model, web parts are replaced with app parts. The problem is they don’t have an equivalent to Web Part Connections. So how can you pass parameters from one part to another?

To answer this you have to consider several things:

  • App parts are basically small applications that are presented in your SharePoint site through iframes
  • each app is running in a separate domain and so are their app parts. Because of this any direct manipulation through some javascript code is out of the question because it would mean cross-domain scripting and all you would get is an “access denied” message

 

This post explains about how to create an user defined custom property for a Client Web Part in SharePoint 2013 Provider Hosted App and its relationship with the query string and the standard tokens. The option for getting the data from Client Web Part’s  custom property is bit  different from Farm based or Sandboxed Web Parts. In Provider Hosted App, the value of the property has to be accessed via query string.

Steps:
1. Add Client web part to app part
2. Open element.xml and add one Property right click on Client web part ->Custom properties-Add ->Ok

testimg

  1. Go to host web where you are having query string
  2. Add App part
  3. Add one script editor web part. It should be below to App.testimg
  4. Now in the App landing page load read the Query string value in .Cs file
  5. protected void Page_Load(object sender, EventArgs e){string _ID = Request.QueryString[“ID”];

    }

.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s