Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > .NET General

Vista - Pass parameters to XBAP from webpage

Reply
 
Old 10-09-2008   #1 (permalink)
Steven Tang


 
 

Pass parameters to XBAP from webpage

I'm creating a XBAP application and want it take some input from webpage
dynamically? what is the best way? how to do it?

Best Regards
Steven

--
=======================
Steven Tang
SYWWUYU)
**

My System SpecsSystem Spec
Old 10-10-2008   #2 (permalink)
Marco Zhou [MSFT]


 
 

RE: Pass parameters to XBAP from webpage

Hello,

Welcome to Microsoft Newsgroup Support Service! My name is Marco Zhou. It's
my pleasure to work with you on this thread.

If I understand you correctly, you need to pass some data from ASP.NET web
pages to the XBAP application, if this is the case, there are two options
you could try out:

First option:

You could use cookie to pass data to XBAP application as follows:
At the codebehind of ASP.NET web page, you could simply write something
like the following:

// Construct the cookies.
HttpCookie cookie = new HttpCookie("MyData");
cookie.Value = HttpUtility.HtmlEncode("MyData");

//Add to the response stream
Response.Cookies.Add(cookie);

// Redirect the page to XBAP delopyment URI.
Response.Redirect("http://localhost/XBapCookieDemo/XBapCookieDemo.xbap");

And in the XBAP application, you could retrieve the cookie using the
following method:

try
{
String cookie = Application.GetCookie(BrowserInteropHelper.Source);
MessageBox.Show(cookie);
}
catch (Win32Exception)
{
}

Second option:

You could use query string to pass data to XBAP application, at the
codebehind of ASP.NET web page, you could write something like the
following:

String data = HttpUtility.UrlEncode("MyData");

// Pass the data using query string.
Response.Redirect("http://localhost/XbapCookieDemo/XbapCookieDemo.xbap?MyDat
a=" + data);

And in the XBAP application, you could retrieve the data using following
method:

String queryString = BrowserInteropHelper.Source.Query;
if (queryString != null && queryString.Length > 0)
{
MessageBox.Show(queryString.Trim('?'));
}

If you want to pass data after the XBAP application has launched, you could
try creating an ASMX or WCF service at the XBAP deployment site, so that
you could communicate data to XBAP application via ASMX and WCF service.

If you have any further questions on this issue, free feel to ask here, we
are glad to answer them.

--------------------------------------------------
Best regards,
Macro Zhou (v-mazho@xxxxxx, remove 'online.')
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msdnmg@xxxxxx.

This posting is provided "AS IS" with no warranties, and confers no rights.

My System SpecsSystem Spec
Old 10-10-2008   #3 (permalink)
Steven Tang


 
 

RE: Pass parameters to XBAP from webpage

Thanks a lot for helping
--
=======================
Steven Tang
SYWWUYU)
**


"Marco Zhou [MSFT]" wrote:
Quote:

> Hello,
>
> Welcome to Microsoft Newsgroup Support Service! My name is Marco Zhou. It's
> my pleasure to work with you on this thread.
>
> If I understand you correctly, you need to pass some data from ASP.NET web
> pages to the XBAP application, if this is the case, there are two options
> you could try out:
>
> First option:
>
> You could use cookie to pass data to XBAP application as follows:
> At the codebehind of ASP.NET web page, you could simply write something
> like the following:
>
> // Construct the cookies.
> HttpCookie cookie = new HttpCookie("MyData");
> cookie.Value = HttpUtility.HtmlEncode("MyData");
>
> //Add to the response stream
> Response.Cookies.Add(cookie);
>
> // Redirect the page to XBAP delopyment URI.
> Response.Redirect("http://localhost/XBapCookieDemo/XBapCookieDemo.xbap");
>
> And in the XBAP application, you could retrieve the cookie using the
> following method:
>
> try
> {
> String cookie = Application.GetCookie(BrowserInteropHelper.Source);
> MessageBox.Show(cookie);
> }
> catch (Win32Exception)
> {
> }
>
> Second option:
>
> You could use query string to pass data to XBAP application, at the
> codebehind of ASP.NET web page, you could write something like the
> following:
>
> String data = HttpUtility.UrlEncode("MyData");
>
> // Pass the data using query string.
> Response.Redirect("http://localhost/XbapCookieDemo/XbapCookieDemo.xbap?MyDat
> a=" + data);
>
> And in the XBAP application, you could retrieve the data using following
> method:
>
> String queryString = BrowserInteropHelper.Source.Query;
> if (queryString != null && queryString.Length > 0)
> {
> MessageBox.Show(queryString.Trim('?'));
> }
>
> If you want to pass data after the XBAP application has launched, you could
> try creating an ASMX or WCF service at the XBAP deployment site, so that
> you could communicate data to XBAP application via ASMX and WCF service.
>
> If you have any further questions on this issue, free feel to ask here, we
> are glad to answer them.
>
> --------------------------------------------------
> Best regards,
> Macro Zhou (v-mazho@xxxxxx, remove 'online.')
> Microsoft Online Community Support
>
> Delighting our customers is our #1 priority. We welcome your comments and
> suggestions about how we can improve the support we provide to you. Please
> feel free to let my manager know what you think of the level of service
> provided. You can send feedback directly to my manager at:
> msdnmg@xxxxxx.
>
> This posting is provided "AS IS" with no warranties, and confers no rights.
>
>
My System SpecsSystem Spec
Old 11-24-2008   #4 (permalink)
abi peter


 
 

Re: Pass parameters to XBAP from webpage

Hi,

Could you pls tell me how to pass data after the XBAP application has
launched, In my application in the main page thier is a tree view and
in the right panel i have a frame with an aspx page as source, where a
file will be uploaded, once upload finish,i want to refresh the tree
view which is in xaml, how could i refresh my xbap from this aspx
page,

please help me to find a way to communicate between these two
different pages,

Thank you,
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Can I pass parameters when opening Word VB Script
XBAP gadget .NET General
Re: powergadget : how to pass parameters PowerShell
Is there a fix for XBAP problem in IE7? Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46