I want to preserve a property between postbacks in an ASP.Net application. Currently doing this:
public int MyIndex { get { return (int)Session[ToString() + "MyIndex"]; } }
but would prefer something like:
public int MyIndex { get { return (int)Session[ToString() + #code_that_returns_property_name#]; } }
Setter omitted, but it just pushes value into Session using the same string. Is there some way to use reflection, or a different better solution?
public static int Dummy { get { var propertyName = MethodBase.GetCurrentMethod().Name.Substring(4); Console.WriteLine(propertyName); return 0; } }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With