469,883 Members | 1,080 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,883 developers. It's quick & easy.

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)
**:)
Oct 9 '08 #1
2 10964
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-*****@online.microsoft.com, 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:
ms****@microsoft.com.

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

Oct 10 '08 #2
Thanks a lot for helping:)
--
=======================
Steven Tang
SYWWUYU)
**:)
"Marco Zhou [MSFT]" wrote:
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-*****@online.microsoft.com, 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:
ms****@microsoft.com.

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

Oct 10 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

13 posts views Thread by Al Franz | last post: by
5 posts views Thread by Ben | last post: by
6 posts views Thread by Woody Splawn | last post: by
3 posts views Thread by Wang Xiaoning | last post: by
3 posts views Thread by Aussie Rules | last post: by
1 post views Thread by Waqarahmed | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.