Silverlight之Frame傳遞多個參數並擷取完整參數

來源:互聯網
上載者:User

          

    if (strXapOrXaml == "xaml")                {                    string[] s = { "ClientBin" };                    //這裡控制是相對位址還是絕對位址                    string url = "";                    if (menuUrl.StartsWith("http://"))                    {                        url = menuUrl.ToString().Trim();                    }                    else                    {                        url = App.Current.Host.Source.OriginalString.ToString().Split(s, StringSplitOptions.RemoveEmptyEntries)[0] + menuUrl.ToString().Trim(new char[] { '.', '/' });                    }                    cpt.frmMain.Navigate(new Uri("/AspxContainer.xaml?tourl=" + url, UriKind.Relative));                     tchA.imgRefresh.Tag = url; //擷取頁面URL地址並賦值 2013-01-30                }

 

這裡比如url中帶多個參數:

./YSQ/page2.aspx?stype=2&sdefault=0

 

<navigation:Page x:Class="WebMain.AspxContainer"            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"           xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"           xmlns:divtools="clr-namespace:Divelements.SilverlightTools;assembly=Divelements.SilverlightTools"           d:DesignWidth="640" d:DesignHeight="480"           Title="AspxContainer Page">    <Grid x:Name="LayoutRoot">        <divtools:HtmlHost x:Name="htmlPlaceholderHost1"  SourceUri="http://www.baidu.com" Margin="0,0,0,0"/>    </Grid></navigation:Page>

 

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.Navigation;namespace WebMain{    public partial class AspxContainer : Page    {        public AspxContainer()        {            InitializeComponent();        }        // 當使用者導航到此頁面時執行。        protected override void OnNavigatedTo(NavigationEventArgs e)        {            if (this.NavigationContext.QueryString.ContainsKey("tourl"))            {                 //載入頁面                string url = e.Uri.ToString().Substring(26); //去掉前面的字串/AspxContainer.xaml?tourl=                this.htmlPlaceholderHost1.SourceUri = new Uri(url, UriKind.RelativeOrAbsolute);            }        }        protected override void OnNavigatedFrom(NavigationEventArgs e)        {            base.OnNavigatedFrom(e);        }    }}

 

 

在重構函數OnNavigatedTo函數中使用參數e的Uri屬性,是解決這個問題的關鍵!

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.