Sign In|Join
Home/Silverlight.NET Forums/General Silverlight Programming/Silverlight Controls and Silverlight Toolkit/redirect to aspx with post
Last post May 26, 2009 05:45 PM by duefectu
Member
2 Points
18 Posts
May 25, 2009 09:05 PM | LINK
Hi guy,
i would call an external webpage aspx from my silverlight project. I know that i can do that in this way:
HtmlPage.Window.Navigate(new Uri("http://silverlight.net/Default?param=pippo"));
But i don't want insert parameter in get request. Can i use Post method? How?
Thanks,
Alessio
Participant
822 Points
270 Posts
May 26, 2009 02:17 PM | LINK
Make a javascript function on the html page and Invoke it.
May 26, 2009 05:45 PM | LINK
The problem is that the only way (that I know) to pass post parameters to another page is to use a <form>.
You can make something like this (there are a lot of ways):
In the .aspx page (html side)
... </form> <form name="AnotherForm" action="newPageUrl.aspx" method="post"> <input type="hidden" id="Parameter1"/> <input type="hidden" id="Parameter2"/> </form> <script language="javascript" type="text/javascript"> function ShowUrl(par1, par2) { try { var hdn1 = document.getElementById("Parameter1"); hdn1.value = par1; var hdn2 = document.getElementById("Parameter2"); hdn2.value = par2; AnotherForm.Submit(); } catch (e) { alert("ERROR: "+e); } } </script> </body> </html>
In the Silverlight .cs code
... string[] s = new string{ "ParameterValue1", "ParameterValue2" }; HtmlPage.Window.Invoke("ShowUrl", s); ...
CAUTION: This code was not tested!
Good look!
drWolf
Member
2 Points
18 Posts
redirect to aspx with post
May 25, 2009 09:05 PM | LINK
Hi guy,
i would call an external webpage aspx from my silverlight project. I know that i can do that in this way:
HtmlPage.Window.Navigate(new Uri("http://silverlight.net/Default?param=pippo"));
But i don't want insert parameter in get request. Can i use Post method? How?
Thanks,
Alessio
Alessio Cocciolo
Consultant - LEFO S.r.l
Email: alessio.c@lefo.it
Tel.: +39 328 18 91 129 Skype: alessio_cocciolo
http://www.lefo.it
http://www.alessiococciolo.it
duefectu
Participant
822 Points
270 Posts
Re: redirect to aspx with post
May 26, 2009 02:17 PM | LINK
Make a javascript function on the html page and Invoke it.
Juan Segura
Plase, "Mark as Answer..." if it solve the problem!
duefectu
Participant
822 Points
270 Posts
Re: redirect to aspx with post
May 26, 2009 05:45 PM | LINK
The problem is that the only way (that I know) to pass post parameters to another page is to use a <form>.
You can make something like this (there are a lot of ways):
In the .aspx page (html side)
...
</form>
<form name="AnotherForm" action="newPageUrl.aspx" method="post">
<input type="hidden" id="Parameter1"/>
<input type="hidden" id="Parameter2"/>
</form>
<script language="javascript" type="text/javascript">
function ShowUrl(par1, par2) {
try {
var hdn1 = document.getElementById("Parameter1");
hdn1.value = par1;
var hdn2 = document.getElementById("Parameter2");
hdn2.value = par2;
AnotherForm.Submit();
}
catch (e) {
alert("ERROR: "+e);
}
}
</script>
</body>
</html>
In the Silverlight .cs code
...
string[] s = new string{ "ParameterValue1", "ParameterValue2" };
HtmlPage.Window.Invoke("ShowUrl", s);
...
CAUTION: This code was not tested!
Good look!
Juan Segura
Plase, "Mark as Answer..." if it solve the problem!