How to pass value from one Silverlight page to another? -


i have 2 .xaml pages loginpage , child page - workloads_new . need pass loginid loginpage workloads_new. in workloads_new keep getting loginid value 0. here code in loginpage:

    void webservice_getuseridcompleted(object sender, getuseridcompletedeventargs e) { int id = e.result; //for example id=2 if (id > 0)     {     this.content = new mainpage();     workloads_new child = new workloads_new();     child.loginid = id; //in debug mode see id=2 , loginid=2     } } 

and in workloads_new have:

    public int loginid { get; set; }  private void childwindow_loaded(object sender, routedeventargs e) {      //to test want see id in textblock keep getting loginid=0 why?      this.errorblock.text = this.loginid.tostring(); } 

the urimapper object supports uris take query-string arguments. example, consider following mapping:

in xaml :

<navigation:urimapping uri="products/{id}" mappeduri="/views/productpage.xaml?id={id}"></navigation:urimapping> 

in c# can see this

consider following code, embeds 2 numbers uri query-string arguments:

string uritext = string.format("/product.xaml?productid={0}&type={1}",productid, producttype);  mainframe.navigate(new uri(uritext), urikind.relative); 

a typical completed uri might this:

/product.xaml?productid=402&type=12 

you can retrieve product id information in destination page code this:

int productid, type; if (this.navigationcontext.querystring.containskey("productid")) productid = int32.parse(this.navigationcontext.querystring["productid"]); if (this.navigationcontext.querystring.containskey("type")) type = int32.parse(this.navigationcontext.querystring["type"]); 

Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

aspxgridview - Devexpress grid - header filter does not work if column is initially hidden -

c# - How to execute a particular part of code asynchronously in a class -