Saturday, February 16, 2013

Jquery Ajax Method Sample


Jquery Ajax Method Sample


$.ajax({
type: 'POST',
      url: "/Flight/FlightAllResult",
      data: ({ 'type': filtertype, 'priceby': priceby }),
      success: function (res) {
                  //var minprice = $(res).find('#HdnMinAmount').val();
                  //var maxprice = $(res).find('#HdnMaxAmount').val();
                  $('#divResults').html(res);
      },
      error: function (res) {
      }
 });

Wednesday, February 13, 2013

How to Remove Array Values Using Javascript

How to Remove Added Values in Javascript

Method 1

 
function removeMilesCode(milesId) {
$("#milescode" + milesId).html("");
var list = document.getElementById('HdnAirlineCodeCheckExists').value.split('|');
var newInvList = '';
   if (list.length > 0) {
       for (var count = 0; count < list.length; count++) {
           if (list[count].split('~')[0] != '') {
               if (list[count].split('~')[0] != milesId) {
                    newInvList += list[count] + '|';
                  }
              }
          }
   }

document.getElementById('HdnAirlineCodeCheckExists').value = newInvList;

}


Method 2

var hidValue = document.getElementById('HdnAddTraveller').value;
var list = hidValue.split('^');
var newInvList = '';
if (list.length > 0) {
for (var count = 0; count < list.length; count++) {
var invesList = list[count].split('~');
                if (invesList[0] != '') {
                 var lista1 = customerValues[1] + '-' + customerValues[2];
                    var listb1 = invesList[0];
                        if (lista1 != listb1) {
                            newInvList += list[count] + '^';
                           }
                     }
              }
         }
   
if (newInvList != '') {
document.getElementById('HdnAddTraveller').value = newInvList;
}

Thursday, January 10, 2013

How to check given string is Integer or not in Server side Using LINQ

bool IsNumber(string s)
{
if (s.Any(c => !Char.IsDigit(c)))
      {
            return false;
      }
      return (s.Length > 0);
}

Wednesday, December 26, 2012

A potentially dangerous Request. Form value was detected from the client (MVC3) How to Solve

A potentially dangerous Request. Form value was detected from the client (MVC3) How to Solve
Add this in Global.asax.cs
protected void Application_Start()
{
      GlobalFilters.Filters.Add(new ValidateInputAttribute(false));
}

Add this in Web.config Under <system.web>

<httpRuntime  requestValidationMode="2.0" />

<pages validateRequest="false">

See Sample Image


 

Friday, November 23, 2012

How to Remove Filter and Soring in dataTable

Remove Sorting and Filter in dataTable

$(document).ready(function () {
        $('#TblAgent').dataTable({ "bSort": false, "bFilter": false});
});

Initial sorting diable

$(document).ready( function() {
  $('#TblAgent').dataTable({
    "aaSorting": []
});
})

Monday, August 27, 2012

Simple SQL Cursor for Reference

SELECT * FROM #tmpTab;           
                DECLARE @x nvarchar(400)
                DECLARE cursorName CURSOR
                FOR Select Kju FROM #tmpTab
                                OPEN cursorName
                                FETCH NEXT FROM cursorName INTO @x
                                WHILE @@FETCH_STATUS = 0
                                                BEGIN
                                                EXEC sp_executesql @x
                                                PRINT @x
                                                FETCH NEXT FROM cursorName
                                                INTO @x
                                                END
                                CLOSE cursorName
                                DEALLOCATE cursorName

Export to Excel from DataTable without using Grid



public void ExportToExcel(DataTable dt)
{
 if (dt.Rows.Count > 0)
 {
 string filename = "DownloadMobileNoExcel.xls";
 System.IO.StringWriter tw = new System.IO.StringWriter();
 System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter(tw);
 DataGrid dgGrid = new DataGrid();
 dgGrid.DataSource = dt;
 dgGrid.DataBind();
 //Get the HTML for the control.
 dgGrid.RenderControl(hw);
 //Write the HTML back to the browser.
 //Response.ContentType = application/vnd.ms-excel;
 Response.ContentType = "application/vnd.ms-excel";
 Response.AppendHeader("Content-Disposition", "attachment; filename=" + filename + "");
 this.EnableViewState = false;
 Response.Write(tw.ToString());
 Response.End();
 }
}