2009年1月27日

Silverlight iFrame

將Silverlight內嵌到使用者的網頁或部落格中,
並可以依照使用者的帳號,顯示相對應的資訊。
可以應用在動畫表情、寵物遊戲、寶寶照片..等等。

  • 提供 user 一組 <iframe> 的語法
    example:
    <iframe style="WIDTH: 400px; HEIGHT: 300px" src="http://dysonliu.blogspot.com/test/TestSilverlight2.aspx?account=Dy&password=1234" frameborder="0" scrolling="no">
    </iframe>
    

  • 建立一個網頁,包含frame,並設定method="post"
    example:
    <body>
    <form id="form1" runat="server" method="post">
    <div">
    <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager>
    </div>
    </form>
    </body>
    
    

  • 利用程式碼產生 Silverlight 物件,並代入參數 example:
    protected void Page_Load(object sender, EventArgs e)
    {
      Silverlight obj = new Silverlight();
      obj.ID = "MySilverlight";
    
      obj.AutoUpgrade = true;
      obj.Enabled = true;
      obj.HtmlAccess = HtmlAccess.SameDomain;
      obj.Visible = true;
    
      obj.Width = 400;
      obj.Height = 300;
      obj.Source = "~/ClientBin/SilverlightParameter.xap";
    
      string acc = Request.QueryString["account"];
      string pss = Request.QueryString["password"];
    
      obj.InitParameters = "account=" + acc + ", password=" + pss;
    
      form1.Controls.Add(obj);
    }
    
  • 在 silverlight 的程式中,可以透過 Application_Startup 取得參數 example:
    private void Application_Startup(object sender, StartupEventArgs e)
    {
      if (e.InitParams.ContainsKey("account") == true &&
                    e.InitParams.ContainsKey("password") == true)
      {
        string account = e.InitParams["account"];
        string password = e.InitParams["password"];
       ...
      }
    
      this.RootVisual = new Page();
    }
    

沒有留言:

Deploying Vue & .NET with Google OAuth on GCP Cloud Run

Deploying Vue & .NET with Google OAuth on GCP Cloud Run Deploying Vue & .NET with Google OAuth on GCP Cloud Run...