Click here to Skip to main content
15,921,884 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I want to use a variable used (that is entered by a user of the application) in another xaml page. How do I do that? For instance if the data entered on the previous page then a certain button must be disabled in another page.
Posted

hi, you can do this by using Query string, or session.
e.g

put some check in the session e.g

session["disablebtn"] = "yes";


and when the next page is loading put a check on the Page_Load event
e.g
 if(convert.ToString(session["disablebtn"]).Equals("yes"))
{

      //  Disable the Button.
}



Let me know if the above solution doesn't help you.

Thanks
 
Share this answer
 
v2
Comments
Christian Graus 4-Jul-11 5:47am    
XAML means he's using WPF, not ASP.NET
If you tag your questions properly, it would help. This is WPF ? If the two pages are not child and parent, if you don't have a direct relationship where you can call a method or set a property, then you should set up a delegate so that when the data changes, it can call a method telling this page to change the state of the button. I'm not sure what you mean by 'previous page', is this perhaps silverlight ? The same rule would apply, a delegate is the best way to communicate between forms.
 
Share this answer
 
Hi, it's a WPF Page and on the 1st page I have :
SQL
sqlIns = "SELECT [Group] FROM [RIMS_DB].[dbo].[Users] WHERE [UserName] = '" + cbUser.Text + "'AND [Password] = '" + pbPass1.Password + "'";


C#
while (dr.Read())
               {
                      groupUs = dr["group"].ToString();
                      if (groupUs == "Admin")
                     {
                       gbwelcome.Visibility = System.Windows.Visibility.Visible;
                      }

else (groupUs == "Admin")
{// blah blah blah}
}

On the 2nd Page I want to call that user logged in which is an admin or any user then disable certain buttons.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900