Wednesday, January 25, 2017

Area registration OR Area routing in MVC C#

Sample
 public override void RegisterArea(AreaRegistrationContext context)   
     {  
       context.MapRoute(  
         "Cpanel_default",  
         "Cpanel/{controller}/{action}/{id}",  
         new { controller="Home", action = "Index", id = UrlParameter.Optional },  
         new [] {"NT.Areas.Cpanel.Controllers"}  
       );  
     }  

Manage css dynamically in razor view based on condition - MVC

Sample
  <div class="col-lg-4 col-md-3 @(app.AppPath=="#"?"disableDiv":"")">  
 Your data  
 </div>  

Redirect to an action in another area in MVC

Sample
 <a href="@Url.Action("Index", "Home",new {area="Cpanel"})">  

Wednesday, May 4, 2016

Jquery for check float numbers on keypress event

Script

 <script type="text/javascript">  
     $(document).ready(function () {  
 $('.isFloat').keypress(function(event) {  
  if ((event.which != 46 || $(this).val().indexOf('.') != -1) && (event.which < 48 || event.which > 57)) {  
   event.preventDefault();  
  }  
 });  
  });  
 </script>  

 <asp:TextBox ID="txtTotlaMark" runat="server" pattern="^[0-9 .]{1,}$" class="isFloat" MaxLength="6" required></asp:TextBox>