1、擷取HTTP串連中的參數
http://localhost:5526/sl.aspx?user=root&password=root
HtmlPage.Document.QueryString
取到的是一個字典IDictionary<string, string>
key=user,value=root
key=password,value=root
2、從“<param name="initparams" value="ChartType=WaterMonitoring" />”中擷取“initparams”參數
e.InitParams["ChartType"].ToString();
3、“HTML:<input type="hidden" name="hf_qty" id="hf_qty" value="705.5" />”中擷取“input元素”
HtmlDocument doc = HtmlPage.Document;
HtmlElement el = doc.GetElementById("hf_qty");
var value = el.GetProperty("value");
4、“與JavaScript互動擷取”
首先在HTML頁面寫一個JavaScript:
<script type="text/javascript">
function GetValue() {
return document.getElementById("hf_qty").value;
}
</script>
在Silverlight代碼裡:
var value = HtmlPage.Window.Invoke("GetValue");
5、“Silverlight”中操作“HTML”元素
HTML:
<div id="myDIV" style="background:blue;width:20%;height:20%">
<asp:Silverlight ID="Xaml1" runat="server"
Source="~/ClientBin/SilverlightApplication27.xap" MinimumVersion="2.0.30930.0"
Width="50%" Height="100%" />
</div>
Silverlight:
private void Button_Click(object sender, RoutedEventArgs e)
{
HtmlDocument doc = HtmlPage.Document;
HtmlElement div = doc.GetElementById("myDIV");
div.SetStyleAttribute("background", "green");
}
幫忙投一票唄
參考部落格:Silverlight和JS互動