28 September 2014

ASP.Net MVC / JQuery - Quick Tips

Setting the TemData in JQuery

    <script type="text/javascript">
        $('#aa').val("test");
        '<% TempData["Test"] = "Test";%>';
    </script>

Adding Tooltip in JQuery

         $(document).ready(function () {

            $(function () {
                $("select option").attr("title", "");
                $("select option").each(function (i) {
                    this.title = this.text;
                })
            });

Check if a request is Ajax request

            //Check if the request is an Ajax request.
            bool IsAjaxRequest = !string.IsNullOrEmpty(Request.Form["x-request-with"] ?? Request.Headers["x-request-with"]);

            //OR.. if you dont like it..use
            bool IsAjaxRequestAgain = Request.IsAjaxRequest();

 

No comments:

Post a Comment