Sunday, May 17, 2015

ASP.NET Get radio button value in javascript

Radio button html

 <input type="radio" name="mxCard" id="mxcard" data-id="<%=mxcard.MxFormaterCreditCard%>" value="<%=mxcard.MxFormaterCreditCard%>" />  


get radio button value in java script


  var selectedVal = "";  
         var selected = $('input[type=radio][name=mxCard]:checked').val();  
         if (selected) {  
           // Do something  
           }  
         }  


Wednesday, May 6, 2015

Detect browser language and other information in ASP.NET

If you just want to detect browser language you can use this

  CultureInfo ci;  
       if (userLanguages.Count() > 0)  
       {  
         try  
         {  
           ci = new CultureInfo(userLanguages[0]);  
         }  
         catch (CultureNotFoundException)  
         {  
           ci = CultureInfo.InvariantCulture;  
         }  
       }  
       else  
       {  
         ci = CultureInfo.InvariantCulture;  
       }  

if you want to get more details then use this


   string browser = HttpContext.Request.Browser.Browser;  
       string version = HttpContext.Request.Browser.Version;  
       string type = HttpContext.Request.Browser.Type;  
       string platform = HttpContext.Request.Browser.Platform;  
       string userAgent = HttpContext.Request.UserAgent;  
       string[] userLang = HttpContext.Request.UserLanguages;  
       var userLanguages = Request.UserLanguages;  


For MVC use this in your Home controller action.



Tuesday, May 5, 2015

Session value show in html ASP.NET

Set the value:

  HttpContext.Current.Session["CVVAndOTPRequiredCardMessage"] = cardNoMessage;  
         HttpContext.Current.Session["CVVAndOTPRequiredCardMessage2"] = cardNoMessage2;  

Show session value in html:


  <p>  
            <%=Server.HtmlEncode(HttpContext.Current.Session["CVVAndOTPRequiredCardMessage"].ToString())%></br>  
            <%=Server.HtmlEncode(HttpContext.Current.Session["CVVAndOTPRequiredCardMessage2"].ToString())%>  
             </p>  

SQL Get all Index create script from Database

To get all script from database as a create new index into another database you can use the following --Get all Index Script SELECT...