How can I change a string value c#

Question:

public static class MyDomain
{
public static string Domain { get { return “MyDomain”; } }
}
I want to change the value of Domain based on the selection of a dropdown box.

How do i do that?

Solution:

Your code will fail because the instance needs to be stored on the application or sesion object. (asp.net destroy all objects that are not stored there once page is rendered)
I attached my own production code (modified with your Domain property), I use this class in my current code and it works OK.
As I said before your issue is how to setup Session properly, follow the link in my previous post and you will be OK
I will suggest to troubleshoot as follows:
- test my code in a brand new web site (session is enabled by default)
- if it works add your user control and see if it works.
- Once the above is working then go to your existing code and find out if they disable session somehow.

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.SessionState;

//namespace deleted, use your own if needed
public static class WebSession
{
private static HttpSessionState CurrentSession
{
get
{
return HttpContext.Current.Session;
}
}
public static string Domain
{
get { return CurrentSession["Domain"] as string; }
set { CurrentSession["Domain"] = value; }
}
}

digg delicious stumbleupon technorati Google live facebook Sphinn Mixx newsvine reddit yahoomyweb
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...