Generic Session Helper


 public static class AllSession
    {

        public static string Get(string key)
        {
            object value = HttpContext.Current.Request.QueryString[key];
            return (value == null) ? null : value.ToString();
        }

        public static string Post(string key)
        {
            object value = HttpContext.Current.Request.Form[key];
            return (value == null) ? null : value.ToString();
        }

        public static string Session(string key)
        {
            object value = HttpContext.Current.Session[key];
            return (value == null) ? null : value.ToString().Trim();
        }

        public static void ClearSession(string key)
        {
            HttpContext.Current.Session[key] = null;
        }

        public static void StoreInSession(string key, object value)
        {
            HttpContext.Current.Session[key] = value;
        }

        public static long TownID
        {
            get
            {

                return GetFromSession<long>(“TownID”);
            }
            set
            {
                SetInSession<long>(“TownID”, value);
            }
        }

        public static string TownName
        {
            get
            {

                return GetFromSession<string>(“TownName”);
            }
            set
            {
                SetInSession<string>(“TownName”, value);
            }
        }
        public static string UnitTime
        {
            get
            {

                return GetFromSession<string>(“UnitTime”);
            }
            set
            {
                SetInSession<string>(“UnitTime”, value);
            }
        }
        public static long UserId
        {
            get
            {

                return GetFromSession<long>(“UserId”);
            }
            set
            {
                SetInSession<long>(“UserId”, value);
            }
        }

        public static void Abandon()
        {
            if (HttpContext.Current != null && HttpContext.Current.Session != null)
                HttpContext.Current.Session.Abandon();
        }

        private static T GetFromSession<T>(string key)
        {
            if (HttpContext.Current.Session == null)
            {
                return default(T);
            }
            object obj = HttpContext.Current.Session[key];
            if (obj == null)
            {
                return default(T);
            }
            return (T)obj;
        }

        private static void SetInSession<T>(string key, T value)
        {
            if (value == null)
            {
                HttpContext.Current.Session.Remove(key);
            }
            else
            {
                HttpContext.Current.Session[key] = value;
            }
        }

        private static T GetFromApplication<T>(string key)
        {
            return (T)HttpContext.Current.Application[key];
        }

        private static void SetInApplication<T>(string key, T value)
        {
            if (value == null)
            {
                HttpContext.Current.Application.Remove(key);
            }
            else
            {
                HttpContext.Current.Application[key] = value;
            }
        }
    }

Advertisements

Call Web Serivce Cross Domain


   var surl = ‘http://localhost:5989/WebService1.asmx/GetCSS?aid=realm&callback=?&#8217;;    
        $.support.cors = true;            
        $.ajaxSetup({ cache: false });
      $.ajax({
            type: “GET”,
            contentType: “application/json; charset=utf-8”,
            url: surl,
            dataType:’jsonp’,
            async: false,                
            crossDomain: ‘true’,              
            success: function (data, textStatus , xhr) {
alert(data);
                    var newCSS = headTag + data;
                     document.getElementsByTagName(‘head’)[0].innerHTML = newCSS;        
            },error: function (error, textStatus , xhr) {
                 alert(‘Error:’ + error.responseText);                   
        }
    });

 

Web Method in Web Service

 [WebMethod(Description = “GetCSS for intellicac”)]
        [ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)]
        public void GetCSS(string aid, string callback)
        {
            if (string.IsNullOrEmpty(aid))
                aid = “occfinance”;
            StringBuilder _tempate = new StringBuilder();
            try
            {
                _tempate.Append(“<style>”);
                string content = System.IO.File.ReadAllText(System.Web.HttpContext.Current.Server.MapPath(@”~\Intellicalc\css\intellicalc.css”));
                _tempate.Append(content);
                using (SqlConnection con = new SqlConnection(Convert.ToString(System.Configuration.ConfigurationManager.ConnectionStrings[“ConString”])))
                {
                    con.Open();
                    using (SqlCommand com = new SqlCommand(“GetsettingDetails”, con))
                    {
                        com.CommandType = CommandType.StoredProcedure;

                        com.Parameters.AddWithValue(“@AffiliateId”, Regex.Replace(aid, “[^a-zA-Z]+”, “”));
                        using (SqlDataReader dr = com.ExecuteReader())
                        {
                            while (dr.Read())
                            {
                                Settingdetails obj = new Settingdetails();
                                obj.settingid = Convert.ToInt32(dr[“settingid”] ?? “1”);
                                obj.name = Convert.ToString(dr[“name”] ?? “barcolors”);
                                obj.settingvalue = Convert.ToString(dr[“value”] ?? “#555555”);

                                _tempate = _tempate
                                  .Replace(“[” + obj.name.Trim() + “]”, obj.settingvalue);
                            }
                            dr.Close();
                        }
                        con.Close();
                        con.Dispose();
                    }
                }
            }
            catch
            {

            }

            _tempate.Append(“</style>”);
            StringBuilder sb = new StringBuilder();
            JavaScriptSerializer js = new JavaScriptSerializer();
            js.MaxJsonLength = Int32.MaxValue;
            sb.Append(callback + “(“);
            sb.Append(js.Serialize(_tempate.ToString()));
            sb.Append(“);”);
            Context.Response.Clear();
            Context.Response.ContentType = “application/json”;
            Context.Response.Write(sb.ToString());
            Context.Response.End();
        }

———

CSS File

.intellicalc *, .icprice_disabled *, .icprice *, .icstepbox * {
    font-family: Arial, Verdana, Tahoma;
    font-size: 12px;
    color: #000000;
    line-height:normal;
}
.intellicalc ul {
    margin:0px;
}
.icclosebutton { border: 0px; }
.property {
    background-color:white;
    border:1px solid gray;
    width:100%;
}
.icslider_point_ie6{position: absolute;width: 15px;height: 76px;background-image: url(‘http://www.beremote.com/img/blank.gif&#8217;);background-repeat: no-repeat;filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=”http://www.beremote.com/img/pointer.png&#8221;,sizingMethod=”scale”)}
.icslider_point{position: absolute;width: 15px;padding-right:30px;padding-bottom:20px;height: 76px;background-image: url(‘http://www.beremote.com/img/pointer.png&#8217;);background-repeat: no-repeat;}
.property #title {
    font-weight:bold;
}
.repossessed {
font-size:10pt;
text-transform:uppercase;
}
.icbanner {
    cursor:pointer;
}
#icpopup .icstepbox {
    margin-left: auto;
    margin-right: auto;
}
#icpopup .icstep1close {
    display:inline!important;
}
#icpopup {
    position:absolute;
    left:0px;
    top:0px;
    width:100%;
    height:600px;
    background-image:url(‘http://www.beremote.com/img/icpopup.png&#8217;);
    display:none;
    text-align:center;
    padding-top:50px;
    z-index: 9999;
}
.iccopy {
    text-align:right;
}
.iccopy a {
    color:silver;
    text-decoration:none;
}
.iclookbelow {
    float: left;
    display: inline;
    font-weight: bold;
    color: [textcolor1] !important;
    padding-left: 4px;
}
#icdiv_side {
    clear: left;
    padding: 7px;
    padding-top: 12px;
    margin-top: 10px;
    border-top: 1px solid #e1e1e1;
}
#icdiv_side, #icdiv_side a {
    font-size: 12px;
}
#icdiv_step1 {
    width: [step1width]px !important;
    text-align:left;    
}
#icdiv_step2 {
    width:950px;
}
#icdiv_step3 {
    border:1px solid gray;
    padding:20px;
    width:[step3width]px !important;
    display:none;
    z-Index:2000;
    text-align:left;
    margin-left: auto;
    margin-right: auto;
}
.inpspan {
    background-color:white;
    border:1px solid gray;
    padding:2px;
}
.inpfield {
    border:0px;
    text-align:right;
    width:105px;
}
#icdiv_step3 .inpfield {
    border:0px;
    text-align:right;
    width:160px;
}
.icbartable {
    width:100%;
    border-top:1px solid silver;
    border-bottom:1px solid silver;
}
.icbartable td {
    border:0px solid red;
}
.icbar_label{
    width:100px;
    font-size:7pt;
    color:[textcolor2] !important;
    padding-top:2px;
}
.icbar {
    margin-left:0px;
    position:relative;
    width:auto;
    height:65px;
}    
    
#icbar_ir {
    height:65px;
    position: relative;
}
#icbar_pp {
    position:relative;
    height:20px;
}
#icbar_mp {
    position:relative;
    height:20px;
}    
#icdiv_ratesld {
    margin-top:-70px;
    margin-left:-7px;
    padding:0px;
    position:relative;
}
.icsel_rategroup {
    font-size:12pt;
    width:780px;
    
}
.icbar_num {
    position:absolute;
    text-align:center;
    width:50px;
    color:[textcolor2] !important;
    border:0px solid red;
}
.icbartext * {
    color:[textcolor2] !important;
}
.icbar_rate {
    position:absolute;
    border:1px solid gray;
    background-color:green;
    padding-right:5px;
    height:33px;
    top:15px;
    text-align:right;
    line-height: 33px!important;
    font-size: 11px;
    font-weight:bold;
}
.icsummary {
    width:100%;
}
.icsummary td {
    padding-left: 0px;
    vertical-align:top;
}
.icsvalues {
    margin:0px;
    padding:0px;
}
.icsvalues li {
    list-style:none;
    float:left;
    padding:5px;
}
.iclabel {    
    font-size:9px;
    color: [textcolor2] !important;
    text-align:left;
}
.icvalue {
    font-size:14px;
    font-weight:bold;
    color:[textcolor4] !important;
    width:90%;
    line-height: 32px!important;
    background-color: [boxcolors] !important;    
}
.iccontainer div {
    float:left;
    display:inline;
}
.icend {
    background-color:  [boxcolors] !important;
    width:5px;
    height:32px;
    filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=”http://www.beremote.com/img/infobox_right.png&#8221;,sizingMethod=”scale”);
}
.icstart {
    background-color:  [boxcolors] !important;
    width:5px;
    height:32px;
    filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=”http://www.beremote.com/img/infobox_left.png&#8221;,sizingMethod=”scale”);
}
.iccontainer {
        background-color:  [boxcolors] !important;
        height:32px;
    line-height: 32px!important;
    text-align:right;
    display:inline;
}
.icvalueactive {
    font-size:14px;
    font-weight:bold;
    color:yellow;
}

.icbutton {
    font-size:12pt;
    color:white;
    background-color:#2262c2;
}
.icinpspan {
    float: left;
    font-weight: bold;
    color: [textcolor1] !important;
    font-size: 14px;
    padding-top: 1px;
    padding-left: 8px;
}
.icstepbox {
    background-color:white;
    border:1px solid silver;
    overflow:hidden;
    width:auto;
    color:gray;
    padding:10px;
}
.icstepbox_padd {
    
}
.iclogo {
    border:0px;
    width:75px;
    float:left;
}
.iclogolarge {
    border: 0;
    width: 170px;
    float: left;
}
.ichead {
    padding-bottom:15px;
}
#icdiv_step3 .ichead {
    padding-bottom: 0px;    
}
.iccontent {
    overflow:hidden;
}
.iccontent table {
    width: 100%;
}
.icfoot {   
    padding:0px;
    text-align:right;
}
#icdiv_step3 .icfoot {
    padding: 10px;
    text-align: left;
    float: none;
}
#icdiv_step3 .icfoot input {
    margin-top: 16px;
}
.ictitle {
    color:[textcolor1] !important;
    font-weight:bold;
    font-size:12pt;
    display: inline;
    margin-top: 2px;
}
.ictitle2 {
    color:[textcolor2] !important;
    font-weight:bold;
    font-size:12pt;
    display: block;
    margin-top: 2px;
    margin-bottom:10px;
}
.ictitle3 {
    color:[textcolor2] !important;
}
.icrepaymentmethods {
    height: 30px;
}
.iclabel1 {
    float: left;
    padding:7px;
    color:[textcolor2] !important;
    margin-right: 10px;
    width: 50px;
}
.iclabel2 {
    float: left;
    color:[textcolor2] !important;
    margin-right: 0px;
    width: 122px;
    padding: 3px 0px;
}
.icvalue1 {
    float: left;
    height: 30px;
    width: 159px;
    background-image: url(‘http://www.beremote.com/img/inputback.gif&#8217;);
    background-repeat: no-repeat;
    background-position: top left;
    margin-right: 10px;
}
.icvalue1_input {
    text-align:right;
    width: 134px;
    float: left;
    margin-top: 6px;
}
.icvalue1_input input {
    font-weight: bold;
}
.icvalue1_help {
    width: 22px !important;
    float: right;
    background-color: [boxcolors] !important;
}
.icvalue1_help img {
    display:block;
}
.icprice_inactive {
    color:gray;
}
.icprice {
    height:20px;
    background-color:[boxcolors] !important;    
    width:180px;
    border:2px outset silver;
}
.icprice table {
    width:100%;
    
}
.icprice td {
    padding:2px;
}
.icenquirebutton {
        background-image:url(‘http://www.beremote.com/img/enquire_default.gif&#8217;);
    background-repeat: no-repeat;
    cursor:pointer;
    width:300px;
    height:67px;
    padding:10px;
    color:[textcolor2] !important;
    text-align:left;
}
.icenquirebutton span {
    color:[textcolor2];
}
.icenquirebutton div {
    width:175px;
    text-align:left;
    font-size:10pt;
}
.icenquirebutton div b {
    color:[boxcolors] !important;
    font-size:10pt;
}
.icprice_td1, .icprice_td3 {
   font-family: Arial, Verdana, Tahoma;
    font-weight: bold;
    color: white;
    font-size: 14px!important;
    width:12px;
    text-align:center;
}
.icprice_td2 {
   font-family: Arial, Verdana, Tahoma;
    background-color:#eeeeee;
    text-align:right;    
}
.icprice_td2 span {
   font-family: Arial, Verdana, Tahoma;
    font-weight:bold;
    color: [textcolor1] !important;
    font-size: 10px;    
}
.icprice_td4 {
    font-family: Arial, Verdana, Tahoma;
        background-image: url(‘http://www.beremote.com/img/apply_left.gif&#8217;);
    background-repeat:no-repeat;
    background-position:left;
    padding-left: 8px;
    padding-top: 4px;
    padding-bottom: 3px;
    padding-right: 10px;
    height:36px;
}
.icprice_td4 span {
   font-family: Arial, Verdana, Tahoma;
    color:[textcolor2] !important;
}
.icprice_td5 {
   font-family: Arial, Verdana, Tahoma;
    background-color: [boxcolors] !important;
    background-repeat:no-repeat;
    background-position:right;
    text-decoration:underline;
    width:100px;
    font-size:8pt;
    padding-left: 8px;
    color:white;
}
.icprice_disabled .icleft_td {
     background-image: url(‘http://www.beremote.com/img/apply_left.gif&#8217;);
    background-repeat:no-repeat;
    background-position:left;
    padding: 7px 8px 8px 8px;
    color: #bbbbbb;
}
.icprice_disabled .icright_td {
    background-color: [boxcolors] !important;
      background-image: url(‘http://www.beremote.com/img/apply_right_disabled.png&#8217;);
    background-repeat:no-repeat;
    background-position:right;
    text-decoration:underline;
    width:70px;
    font-size:10px;
    padding: 8px;
    color:white;
}
.icprice_button {
    background-color: [boxcolors] !important;  
    padding:2px;
    color:white;
    width:130px;
    font-weight:bold;    
    border:1px outset gray;
    cursor:pointer;     
    text-align:right;
}
.icprice_disabled #icbestprice {
    font-weight:bold;
    color: #d3d3d3;
    font-size: 11px;
}
.icprice .icfullprice {
    font-size: 11px; color: [textcolor3] !important;
}
.icprice_disabled .icfullprice {
    font-size: 11px; color: #bbbbbb;
}
.icstep2back {
    display: inline;
    margin-top: 2px;
}
.icstep2back a {
    color: [textcolor1] !important;
    font-weight:bold;
    font-size:12pt;
    text-decoration: none;
}
.icstep1close {
    display: none;
    margin-top: 2px;
}

#icshowmebutton, #iccancelbutton, #iccancelbutton1 {
    height: 30px;
    font-weight: bold;
    width: 125px;
    color: [textcolor1] !important;
}
#icupdatebutton {
    height: 35px;
    font-weight: bold;
    width: 125px;
    color: [textcolor1] !important;
}
#icsubmitbutton {
    height: 30px;
    font-weight: bold;
    width: 125px;
    color: [textcolor1] !important;
}

.icstep3label {
    color:[textcolor3] !important;
}
.icstep3value {
    height: 30px;
    padding-top: 5px;
    text-align: right;
      background-image: url(‘http://www.beremote.com/img/step3_input.gif&#8217;);
    background-repeat: no-repeat;
    background-position: left top;
}
.icstep3value input {
    border: 0px;
    width: 180px;
    margin-right: 7px;
}
.icstep3field {
    padding:10px;
    float: left;
    clear: left;
}
.icstep3field .licstep3abel {
    width:200px;
}
.icstep3field .icstep3value {
    width:200px;
}
#icvloan, #icvdeposit {
    text-align:right;
}
/* END */
.icprice_widget {
  background-image: url(‘http://www.beremote.com/img/icalcbutton-question.png&#8217;);
  background-repeat:no-repeat;
  cursor:pointer;
  padding-left:22px;
  padding-top:2px;
 
  font-size:8pt!important;
  text-decoration:none;
  height:20px;
  width:140px;
  color:black!important;
  overflow:hidden;
  text-align:left;
  font-weight:normal;
    font-family: Arial, Verdana, Tahoma;
}
.icprice_widget_inactive {
    font-family: Arial, Verdana, Tahoma;
  background-image: url(‘http://www.beremote.com/img/icalcbutton-question.png&#8217;);
  background-repeat:no-repeat;
  cursor:pointer;
  padding-left:22px;
  padding-top:2px;
  font-size:8pt!important;
  text-decoration:none;
  height:20px;
  width:120px;
  color:gray!important;
  overflow:hidden;
  text-align:left;
  font-weight:normal;
}
.icbannertext {
    position:absolute;
    color:[textcolor2] !important;
        top:55px;
    padding-top:5px;
    padding-left:5px;
}
.icbannertext b {
    color:[boxcolors] !important;
}
.ictext {
    color:[textcolor2] !important;
    padding-bottom:10px;
    padding-top:10px;
    overflow:hidden;        
}
.icbubble {
    background-color: [boxcolors] !important;
    color:white;
    padding:10px;
}
#icwhatisthis {
    z-index:2001;left:35px;top:35px;width:600px;height:500px;position:absolute;border:1px solid black;color:white;
    padding:20px 20px 20px 20px;
    background-color:#333333;
    display:none;
}
#icwhatisthis p, #icwhatisthis li  {
    font-size:12px;
    color:white;
}

#icwhatisthis ul {
    margin-left:20px;
}
.icalc_bubble { height: 50px; }
.icalc_bubble_bg { font-size: 10px; font-weight: bold; color: #3a3a3a; background-image: url(‘http://www.beremote.com/img/icalc_bubble_bg.gif&#8217;); background-repeat: repeat-x; }
.icstepbox table td { border: 0px; }
.icstepbox ul li {margin:0px; }
.icalc_bubble td { padding: 0px; text-align:center; vertical-align:middle; }
.icbar_label {vertical-align:middle; }