<%@ Page Language="C#" autoEventWireup="true" CodeBehind="Index.aspx.cs" inherits="test.Index" %><!DOCTYPE HTML PUBliC "-//W3C//DTD xhtml 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-Transitional.dtd"><HTML xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> <Title></Title> <script src="Scripts/jquery-1.4.1.min.Js" type="text/JavaScript"></script> <script src="Silverlight.Js" type="text/JavaScript"></script> <script type="text/JavaScript"> function onSilverlightError(sender,args) { var appSource = ""; if (sender != null && sender != 0) { appSource = sender.getHost().source; } var errorType = args.ErrorType; var IErrorCode = args.ErrorCode; if (errorType == "ImageError" || errorType == "MediaError") { return; } var errMsg = "Silverlight 应用程序中未处理的错误 " + appSource + "\n"; errMsg += "代码: " + IErrorCode + " \n"; errMsg += "类别: " + errorType + " \n"; errMsg += "消息: " + args.ErrorMessage + " \n"; if (errorType == "ParserError") { errMsg += "文件: " + args.xamlfile + " \n"; errMsg += "行: " + args.lineNumber + " \n"; errMsg += "位置: " + args.charposition + " \n"; } else if (errorType == "RuntimeError") { if (args.lineNumber != 0) { errMsg += "行: " + args.lineNumber + " \n"; errMsg += "位置: " + args.charposition + " \n"; } errMsg += "方法名称: " + args.methodname + " \n"; } 引发新错误(errMsg); } </script></head><body> <form ID="form1" runat="server"> <div> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional"> <ContentTemplate> <input type="button" value="查询" ID="btnSearch" /> <div > <object ID="SL" data="data:application/x-silverlight-2," type="application/x-silverlight-2" wIDth="100%" height="700px"> <param name="source" value="ClIEntBin/SL.xap" /> <param name="onError" value="onSilverlightError" /> <param name="background" value="white" /> <param name="minRuntimeVersion" value="4.0.60310.0" /> <param name="autoUpgrade" value="true" /> <param name="windowless" value="true" /> <a href="http://go.microsoft.com/fwlink/?linkID=149156&v=4.0.60310.0" > <img src="http://go.microsoft.com/fwlink/?linkID=161376" alt="获取 Microsoft Silverlight" /> </a> </object> </div> </ContentTemplate> </asp:UpdatePanel> </div> </form></body></HTML><script type="text/JavaScript" language="JavaScript"> $(document).ready(function () { $("#btnSearch").click(function () { getMess(); }); }); function getMess() { $.post("Index.aspx",{ "action": "search","param": "level" },function (data) { setTimeout(function () { var slHost = document.getElementByID("SL"); var page = slHost.Content.Page; page.process(data); },1000); }); }</script>
using System;using System.Collections.Generic;using System.linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;using System.Text;namespace test{ public partial class Index : System.Web.UI.Page { protected voID Page_Load(object sender,EventArgs e) { if (!IsPostBack) { if (Request["action"] != null) { if (Request["param"] != null) { System.Web.Script.Serialization.JavaScriptSerializer Jss = new System.Web.Script.Serialization.JavaScriptSerializer(); StringBuilder sb = new StringBuilder(); sb.Append(Request["param"].ToString()); string strs = Jss.Serialize(sb.ToString()); Response.Write(sb.ToString()); Response.End(); } } else { } } } }}
<UserControl x:Class="SL.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/Expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" d:DesignHeight="300" d:DesignWIDth="400"> <GrID x:name="LayoutRoot" Background="White"> </GrID></UserControl>
using System;using System.Collections.Generic;using System.linq;using System.Net;using System.windows;using System.windows.Controls;using System.windows.documents;using System.windows.input;using System.windows.Media;using System.windows.Media.Animation;using System.windows.Shapes;using System.windows.browser;namespace SL{ public partial class MainPage : UserControl { public MainPage() { InitializeComponent(); HTMLPage.RegisterScriptableObject("Page",this); } [ScriptableMember] public voID process(string arg) { if (arg.Length > 0) { MessageBox.Show(arg); } } }}总结
以上是内存溢出为你收集整理的aspx页面中点击按钮传递给Silverlight,并且页面不刷新全部内容,希望文章能够帮你解决aspx页面中点击按钮传递给Silverlight,并且页面不刷新所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)