2012-02-07 7 views
7

Mi proyecto es un proyecto de Silverlight navighation (en el navegador) quiero para navegar a una URL como:de navegación y enviar los datos de Silverlight

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", ""); 

y enviar muchos parámetros con el método POST a la página

objetivo

¿cómo puedo hacer esto?

Respuesta

7

No puede Navigate() y sigue usando POST. Navigate es el equivalente a hacer clic en un enlace o escribir una URL en la barra de direcciones, que invoca el verbo GET.

para utilizar el poste, en su lugar puede utilizar el navegador Silverlight interoperabilidad para crear mediante programación un archivo HTML <form>, establezca su atributo action a la URL correcta, establezca su atributo target-"_blank", añadir algunos <input type="hidden"> campos, establecer sus nombres y valores y luego submit() el formulario.

// 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"); 
+0

gracias, ha sido útil – Masoomian

Cuestiones relacionadas