浏览和发布Silverlight的数据 [英] navigate and post data from silverlight

查看:89
本文介绍了浏览和发布Silverlight的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的项目是Silverlight的navighation项目(在浏览器中)
我想导航到一个URL,例如:

My project is silverlight navighation project (IN-Browser) I want to navigate to an Url such as :

System.Windows.Browser.HtmlPage.Window.Navigate(new Uri(string.Format("http://{0}:
{1}/ReportProject.aspx#/Supplies/RequestGoods/RequestGoodsDashboard", 
Application.Current.Host.Source.Host, 
Application.Current.Host.Source.Port)), "_blank", "");

和发送多个参数用POST方法目标页面

and send many parameters with post method to target page

我怎么能这样做呢?

推荐答案

您不能导航()并仍然使用POST。 导航是点击一个链接或输入在地址栏,它调用GET动词URL的等价物。

You cannot Navigate() and still use POST. Navigate is the equivalent of clicking a link or typing a URL in the address bar, which invokes the GET verb.

使用POST,你也可以使用Silverlight的浏览器互操作以编程方式创建一个HTML <形式> ,设置其动作属性正确的URL,设置其目标属性_空白,添加一些<输入类型=隐藏> 字段中,设置它们的名称和值,然后提交()的形式

To use POST, you could instead use the Silverlight browser interop to programmatically create an HTML <form>, set its action attribute to the correct URL, set its target attribute to "_blank", add some <input type="hidden"> fields, set their names and values and then submit() the form.

// Get document and body
var doc = System.Windows.Browser.HtmlPage.Document;
var body = doc.Body;

// Create a <form> element and add it to the body
var newForm = doc.CreateElement("form");
newForm.SetAttribute("action", targetUrl);
newForm.SetAttribute("method", "post");
body.AppendChild(newForm);

// TODO: doc.CreateElement("input");
// TODO: SetAttribute("type", "hidden");
// TODO: SetAttribute("name", someName);
// TODO: SetAttribute("value", someValue);
// TODO: newForm.AppendChild()

newForm.Invoke("submit");

这篇关于浏览和发布Silverlight的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆