Monday, June 6, 2011

Simple but time consuming things

  1. The HttpPost was not called when hitting  submit button in MVC view
   This was fixed by including(in some cases)

   <%using (Html.BeginForm())
          {%>


 2. The Request.Files  empty issue
   This will be recovered by using mutipart post method
    
    <%using (Html.BeginForm("Fileupload", "Home", FormMethod.Post, new { enctype = "multipart/form-data" }))
          {%>

//Action Name, Controller in begin form method 

 3. To ensure tat end date is greater than the start date using jquery concept. The following is the code




$('#StartDate').datepicker().change(function () {
            $('#EndDate').datepicker("destroy");//Here destroying the dates
            $('#EndDate').datepicker({ minDate: new Date($("#StartDate").val()), maxDate: "+1M +10D" });
//By here we enabling the date greater than start date we selected
        });
4. Converting default Datetime format to required datetime format in MVC when displaying
      First we need to get tat value in another datetime variable and then need to convert it to string for required format as like below:


<%var Startdate=Convert.ToDateTime(item.LeaveStartDate);%>
            <%=Startdate.ToString("dd/MM/yyyy")%>

No comments:

Post a Comment