Saturday, 15 May 2010

c# - get the value from one master to another -


Iam using the dropdown list in a master page. I want to get a dropdown list value in the session and I want to use it in any other master page.

How to do this.

To enter the selected value in the session, you can do something like this:

< Pre> safe void ddlMyDropDown_SelectedIndexChanged (object sender, EventArgs e) {session ["MySelectedValue"] = ddlMyDropDown.SelectedValue; }

This key stores the value selected in the session with "MySelectedValue".

When you want to read it back, you can:

my string = "[MySelectedValue"] < P> It may be an idea that wrap your access to a class in the session, so that everyone can be typed strongly, and allows you to add verification or other logic:

  // session data fully accessed for public class MySessionData {// logged in user's current user name sub Yogener names are, otherwise void Public string MyUsername {get {return session ["MyUsername"]; } Set {session ["MyUsername"] = value; }}}  

No comments:

Post a Comment