Category: Jquery

windows.location navigation error

If beforeupload function is attached to windows and any event/ function changes the windows.location and we choose “Stay on this page” it will through error. We need to use try catch for the solution. binding beforunload event for page $(window).on(‘beforeunload’, function(e){ return “must”  }); following code is solution for if we called ajax call and using callback with change windows… Read more →

Is form is durty

function GetFormData() { oForm.Add(‘span’, $(‘span:not(:disabled)’).toEnumerable().ToObject(“i=>i.attr(‘name’)”, “i=>(‘:disabled’)?”:i.text())”)); oForm.Add(‘input’, $(“input:not(:disabled)”).toEnumerable().ToObject(“i=>i.attr(‘name’)”, “i=>i.val()”)); } function isModifiedForm(au) { var oChangeForm = $.Enumerable.Empty().ToDictionary(); oChangeForm.Add(‘span’, $(‘span:not(:disabled)’).toEnumerable().ToObject(“i=>i.attr(‘name’)”, “i=>(‘:disabled’)?”:i.text())”)); oChangeForm.Add(‘input’, $(“input:not(:disabled)”).toEnumerable().Where(“i=>i.attr(‘name’)!=’tags’”).ToObject(“i=>i.attr(‘name’)”, “i=>i.val()”)); var tempEnumB=Enumerable.From(oChangeForm.Get(“input”)); var tempEnumA=Enumerable.From(oChangeForm.Get(“input”)); var NoofInputChanged = false; var NoofSpanChanged = false;   var hasInputChanges = tempEnumB.Count() != tempEnumA.Count(); if (hasInputChanges) { NoofInputChanged = tempEnumB.Join(tempEnumA, “i=>i.Key”, “o=>o.Key”, “i,o=>{K:i.Key, IsEq:(i.value==o.value)}”).Where(“x=>x.IsEq==false”).Count(); }   tempEnumB=Enumerable.From(oChangeForm.Get(“span”)); tempEnumA=Enumerable.From(oChangeForm.Get(“span”));   var hasSpanChanges =… Read more →

Event preventDefault and stopPropagation difference

Event preventDefault: The event.preventDefault() method stops the default action of an element from happening. For example: Prevent a submit button from submitting a form Prevent a link from following the URL Event stopPropagation : The event.stopPropagation() method stops the bubbling of an event to parent elements, preventing any parent event handlers from being executed. -following link to get more about this event—… Read more →

Difference between document.ready and window.onload or pageLoad

$(document).ready() Best for onetime initialization. Called as soon as DOM is ready; may called slightly before than pageLoad(). Cross browser compatible. Unable to re-attach the functionality to elements/controls of the page affected by partial postbacks. pageLoad() Not best for onetime initialization if used with UpdatePanel. Not Cross browser compatible. Best to re-attach the functionality to elements/controls of the page affected… Read more →

HTTP Request Methods: GET and POST

Two HTTP Request Methods: GET and POST Two commonly used methods for a request-response between a client and server are: GET and POST. GET – Requests data from a specified resource POST – Submits data to be processed to a specified resource The GET Method Note that query strings (name/value pairs) is sent in the URL of a GET request:… Read more →

jQuery library method that load data from server

The jQuery library has a full suite of Ajax capabilities. The functions and methods therein allow us to load data from the server without a browser page refresh. $.ajax() Performs an asynchronous HTTP (Ajax) request basically this is a method of jquery which internally uses xmlhttprequest object of JavaScript as asynchronous communicator which supports cross browser also. There is lots of… Read more →

Attribute and Properties in jquery

What actually is Attributes? Attributes carry additional information about an HTML element and come in name=”value” pairs. we can set an attribute for HTML element and define it while writing the source code. <input id=”test” value=”test” type=”test”> here, “type”,”value”, “id” are attributes of the input elements.   What is Property? Property is a representation of an attribute in the HTML… Read more →

updated questions in .Net topic

— Check if my model is valid from inside the razor view? Gets the model state dictionary object that contains the state of the model and of model-binding validation. if (ModelState.IsValid){} —write validation in view <div> @using (Html.BeginForm(“Create”, “Client”, FormMethod.Post, new { @class = “form-horizontal”, role = “form” })) { <div> <div>@Html.LabelFor(m => m.Name) <span>@Html.ValidationMessageFor(model => model.Name)</span></div> <div>@Html.TextBoxFor(m => m.Name,… Read more →

jQuery Validation

<!DOCTYPE html> <html xmlns=””> <head> <title>Validation</title> <link href=”” rel=”stylesheet” /> <script src=””></script> <script src=””></script> <script src=””></script> <script type=”text/javascript” src=””></script> <script type=”text/javascript”> $(document).ready(function () { jQuery(“#MyForm”).validationEngine(); }); </script> </head> <body> <form id=”MyForm” class=”formular” method=”post”> <br /><br /><br /> <input id=”Text1″ type=”text” class=”validate[required,custom[integer],max[50]] text-input” /><br /><br /> <input id=”Text2″ type=”text” class=”validate[required] text-input” /><br /><br /> <input id=”Text3″ type=”text” class=”validate[required] text-input” /><br /><br… Read more →