Sunday, 9 February 2014

How to call a method in mvc4.0 using jquery ajax.

To call a method in mvc4.0 we can do it by using jquery ajax
$(document).ready(function () {
 $("#btnCreate").click(function () {
           $.ajax({
                 type: "GET",
                 url: '@Url.Action("GetRecords", "Status")',
                data: { strStatusValue: value },
                success: function (data) { },
                            error: function (error) {
                                $(".loading").hide();
                            }
                        })
            });
});
Note : Here i am getting value from from data "strStatusValue". using that we will get the records based on the value.

        [HttpPost]
        public JsonResult GetDetailsUsingId(string strEmailId)
        {

            DataSet ds = new DataSet();
            string procedureName = "getUserDataAccessTabs";
            SqlParameter[] Params = new SqlParameter[1];
            Params[0] = new SqlParameter("@userId", strEmailId);
            ds = DataAccess.SqlHelper.ExecuteDataset(ConnectionString,         CommandType.StoredProcedure,      procedureName, Params);
            return  Json(ds , JsonRequestBehavior.AllowGet);
        }

the above method will return the record based on "strStatusValue".

Here i used jquery ajax for partial rendering in the click event.

How to remove nulls in a table using jquery.

$('td:contains("null")').text('');

The above code replace nulls with ''.

Friday, 7 February 2014

how to view our web page center alignment in IE

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

IE is ok with this arrangement.

We have to add this at the top of the page.


<html>
<div style="width: 100%">
    <div style="width: 500px; margin: auto">

           </div>
</div>
The above is for content purpose.