Skip to main content

Posts

Showing posts with the label MVC 4

asp.net mvc add & remove item from html table

To add & remove item in HTML table like this image you can like the this: Model: public class StudentDetailsModels { public System.Guid? StudentId { get; set; } public System.String StudentName { get; set; } public System.String StudentFatherName { get; set; } public System.String StudentAddress { get; set; } } public class StudentModels { [Key] public System.Guid? StudentId { get; set; } public System.String StudentName { get; set; } public System.String StudentFatherName { get; set; } public System.String StudentAddress { get; set; } private List<StudentDetailsModels> _studentDetailsList = new List<StudentDetailsModels>(); public List<StudentDetailsModels> StudentDetailsList { get { return _studentDetailsList; } set { _studentDetailsList = value; } } } View: @{ ViewBag.Title = "StudentInfo"; ...

ASP.NET MVC Mail Sending with attachment file

You can send mail with attach file using the code MailMessage mail = new MailMessage(); SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com"); mail.From = new MailAddress("atiour.islam@gmail.com"); mail.To.Add("atik.kotha@gmail.com"); mail.Subject = "Test"; mail.Body = "Hi"; System.Net.Mail.Attachment attachment; attachment = new System.Net.Mail.Attachment("D:\\ff.pdf"); mail.Attachments.Add(attachment); SmtpServer.Port = 587; SmtpServer.Credentials = new System.Net.NetworkCredential("atiour.islam@gmail.com", "password"); SmtpServer.EnableSsl = true; SmtpServer.Timeout = 60000; SmtpServer.Send(mail);

mvc controller post action not working

some times we see that the post is not work, like as button or other. we can manage it using form and script to serialize the form to reach our controller action. define your action path, form id and method type in your form. <form id="subscriptionForm" action="/Category/Create" method="post">   <div class="form-horizontal"> <h4>PIS_tblCategory</h4> <hr /> @Html.ValidationSummary(true) <div class="form-group"> <div class="form-group"> @Html.LabelFor(model => model.CategoryName, new { @class = "control-label col-md-2" }) <div class="col-md-10"> @Html.EditorFor(model => model.CategoryName) @Html.ValidationMessageFor(model => model.CategoryName) </div> </div> <div class="form-group"> @Html.LabelFo...

asp.net mvc how to separate module wise controller, model, view

First take a look on this. http://stackoverflow.com/questions/5243158/how-to-configure-areas-in-asp-net-mvc3 In ASP.NET MVC application MVC gives use 3 part Controller, Model & View . But if we want to separate the  Controller, Model & View as our application Module based we can also implement this using AreaRegistration . Consider i want to use PIS module with seperated Controller, Model & View . i have to add a user define class, i just named it PISAreaRegistration . public class PISAreaRegistration : AreaRegistration { public override string AreaName { get { return "PIS"; } } public override void RegisterArea(AreaRegistrationContext context) { context.MapRoute( "PIS_default", "PIS/{controller}/{action}/{id}", new { action = "Index", id = UrlParameter.Optional } ); } } if you ...

mvc pass value in controller from script

Consider the following example i am firing the script with a list value using for loop table data. <a href='#' class="gridEdit" onclick="javascript:return DeleteServiceOut('@Model.EmployeeInformationList[i].GEmployeeGenInfoID.ToString()');"></a> the function to pass values to controller from Javascript code in MVC <script> function DeleteServiceOut(GEmployeeId) { window.location = "/PMS/Payroll/ServiceOutAdd/ServiceOutDelete/" + GEmployeeId; return false; } </script> in to the controller public ActionResult ServiceOutDelete(string id, ServiceOutModels model) { // id will contailn the value of parameter // AS you want return View("ServiceOutViewDetails", model); }

How to disable specific grid column in kendo ui Grid on inline editing

If you want to stop editing on specific Grid column in Kendo Ui grid like this Just use theDataAnnotations [ Editable ( false )] in your custom class for the grid i am just share my code for your help using System; using System . Collections . Generic; using System . ComponentModel . DataAnnotations; using System . Linq; using System . Web; namespace FEWO . ViewModel { public class Limitation { public long Id { get; set; } public int? LFDNR { get; set; } public Guid? ob_guid { get; set; } public DateTime? von { get; set; } public DateTime? bis { get; set; } public string einschrank { get; set; } public string wtagvon { get; set; } public string wtagbis { get; set; } public int numtagvon { get; set; } public int? numtagbis { get; set; } public int? nummonvon { get; set; } public int? nummonbis { get; set; } public int? numjahrvon { get; set; } public ...