Posts

Showing posts from 2013

CREATE-REMOVE-ADD IN JSON USING JAVASCRIPT

//CREATING JSON OBJECT         var Obj = { Languages: [] };         //ADDING ITEMS TO JSON OBJECT         Obj.Languages.push({ id: "1", Name: 'C Language' });         Obj.Languages.push({ id: "2", Name: 'C++ Language' });         Obj.Languages.push({ id: "3", Name: 'JAVA' });         Obj.Languages.push({ id: "4", Name: 'JAVASCRIPT' });         Obj.Languages.push({ id: "5", Name: 'JQUERY' });         //REMOVING ITEMS FROM JSON OBJECT         Obj.Languages.pop();         //REMOVING PARTICULAR ITEM FROM JSON OBJECT         Obj.Languages.splice(2, 1);         //ADDING NEW ITEM IN MIDDLE         //SIGNATURE OF splice(INDEX, COUNT TO DELETE FROM INDEX, JSON OBJECT TO ADD NEW ITEM)         Obj.Languages.splice(2, 0, { id: 5, Name: 'DOTNET' });

CALCULATING DISTANCE BETWEEN TWO PLACES ASP.NET

Calculating distance between two places made easy by GOOGLE MAP's DISTANCE MATRIX .  Google Map Matrix is an opensource api which will return Json & Xml as responces for its each request. Here we can get google map search suggestions too using google map's javascript api.  By this the text box you enter for desired place will show you google map's search suggestions. Let go to code. Html in aspx file: <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server">     <title>Google Maps</title>     <script src="https://maps.googleapis.com/maps/api/js?sensor=false&libraries=places"         type="text/javascript"></script>     <script type="text/javascript">         //for getting origin autocomplete google map results         function OrginAutoComplete() {             try {                 var input = document.getElementById('TextBox

JSON WEBSERVICE IN ASP.NET

JSONASPNET.zip Here we will see how to return json from asp.net webservice and how to use in our html or aspx page. EXPLANATION: Json is one of the data transfer format like xml.  JSON stands for JAVA SCRIPT OBJECT NOTATION. Now a days may of the application like Google, Facebook, Twitter etc., are using JSON as their data transfer format.  As an asp.net developer you can parse this JSON both in backend coding like C# and client script like JAVASCRIPT.  Taking help of JQuery will be added advantage in parsing the json content. By using a jq uery you can easily call a webservice without any backend technology.  In this case you can create a asp.net webservice that returns json and call you can call it in both html or aspx pages.  This makes webpages lighter & faster. PROCEDURE : Lets create a New asp.net empty website project.  Add webservice with your desired name.  Add the following name spaces System.Web.Script.Serialization & System.Web.Scrip

App_Offline.htm in ASP.NET

One of the most useful features of ASP.NET is the “App_Offline.htm” . It provides a much easy way to make the ASP.NET application offline while we do our modifications on the site. How we do it? We just create a file and name it exactly  as ‘app_offline’ and place it in the root of a web application directory that we have configured within IIS., This will make the site offline, unload the application domain from the server, and stop processing any new incoming requests for that application.It will serve the contents of the app_offline.htm file in response to all new dynamic requests for the application. How we make the site online? Once we rename/remove the App_offline.htm file, the next request into the application will cause ASP.NET to load the application and app-domain again, and it will be back to normal. This feature is first introduced in ASP.NET 2.0 and it is available now in all the later versions. Just give the App_offline.htm page's content as follows.  This will be dis

Postback Issue and retrieving values - asp.net dynamic controls

In my last post “ CREATINGCONTROLS DYNAMICALLY IN ASP.NET ” I have explained about creating controls dynamically in asp.net. Postback Issue Solving : By creating controls dynamically for each and every post back the controls will get cleared.  This is due to the lack of initialization of these controls.  If we initialize an asp.net server control in aspx page then there is no need of initializing this control every time, objects will be initiated while parsing the aspx page itself.  By in case of dynamically created controls there will not be any initialization in postbacks so the solution for the controls to stay at postback is – Creating the controls on page load and repeating the creation process in each and every postback.  Now after a change my cs file’s code will look like as follows     protected void Page_Load( object sender, EventArgs e)     {         if (hdfTemp.Value == "1" ) { CreateForm(); }     }     protected void btnGenerateForm_Click( o

Dynamic Controls in ASP.NET

The situation may occur that controls to be created dynamically at runtime, these controls should react for their events i.e., dynamically generated controls should be event driven.  For handling these kinds of situations this post will be very useful.  First of all we will see how to create and show controls on the form dynamically with an example.  In this example I’m creating a form with one label and one textbox aligned in a table control. In asp.net, every control can be added as a child control for other container controls like placeholder control, panel control etc.  In this way here also we will create controls and add those controls to one of the parent controls. Create a place holder control which will hold our dynamically created controls. Create a button in which on this button click we are creating and showing controls on the page.   The code which I have written in aspx page will be as follows. < asp : Button ID ="btnGenerateForm" runat =&q

Image resizing in asp.net

Introduction :-             This tutorial will show you how to generate image thumbnails dynamically from an original big image. Background :-             Many of the web developers will show the big images as small by giving the attribute values for the image tag.  This will slow down the webpage loading.  For better performance the best method is creating the small thumbnail images for showing small size image on the web pages.  But for every upload of the images by the user we cannot create a thumbnail image, it’s a tedious process.  I planed to create a method which will create a thumbnail automatically while the image upload and saves in a separate path.  This is a light weight process and easy to use.  The only thing is you have to add one more filed for saving the thumbnail image path while dealing with databases. Following are the features of this technique. Good Quality. Desired thumbnail size. Using the code :-             Below is the method which