Wednesday, September 29, 2010

AjaxPro

These days we use Ajax technologies in every page for the faster action, to make network traffic less, to refresh the needed parts of the page. We are using Ajax in .net, html, php, java etc.. Among this we are using AjaxPro which is also ajax, but here the codes are precompiled into dll file. Just we have to use this AjaxPro. 

Why we have to use AjaxPro?
The real need arises when we want to communicate directly from javascript to AppCode class files. Means after once form values has been entered we are passing the form values directly into the AppCode class file using Javascript. At that time we are using this AjaxPro. 

There are two methods by which we can use this AjaxPro.
  1. In the first one we fetch the values, and javascript will pass it into one js file. From that js file values are reflected back into aspx page code behind, where in that code behind class will be called.
  2. In second one we fetch the values of the form using Javascript and send it into AppCode class file and there process all the things.
Now lets have a look at the second method:

  1. First we have to place AjaxPro2.dll and its refresh file in the bin folder.
  2. In webconfig file add the following code , inside the

                                                                                   
  3. In aspx page for the particular button click call the javascript function.
  4. Inside the javascript in aspx page write the function code and call the class
    from appcode and function from the appcode class file as ajax.add(name).
    here ajax is the class file and add is the function and pass the parameters.
  5. In codebehind of aspx page add “using System.Text;” & “using AjaxPro”
    namespaces.
  6. Call the appcode class file as normally in the apsx code behind file.
  7. In page_load  event of the aspx page code behind insert the following code :
    AjaxPro.Utility.RegisterTypeForAjax(typeof(ajax));
    Here “ajax” is the appcode classfile name where the corresponding stored
    procedures are there.
  8. In appcode class file add” using AjaxPro” namespace.
  9. On top of each function in classfile add [AjaxMethod] sentence.




Monday, September 27, 2010

Adding Fav-Icons to websites

Whenever we open a webpage or visit a website we see one icon at the starting in the address bar. That icon is know as "Fav-Icon" or logo/symbol for that company or page. This favicon is useful for recognizing pages, creating bookmarks etc...

we can add this fav-icons easily in webpages. Here are the couple of steps which describes how to adding fav-icons.
At first we have to create the icon images in order to display. You can create using adobe photoshop or in online you can use http://www.favicon.cc/  this website in order to create icon images.
After creating the icon images, place that image in root folder of the pages and within ...tag insert the following code

"link href="flower.ico" rel="shorcut icon" type="image/ico"

and in href give link to icon image.

After this when you run the page, image will display in address bar.

Here we can do this asp.net also. There also we can follow the same procedure, in link tag add the following property

rel="shortcut icon" href="<%=ResolveUrl("~/minto1.ico")%>"

in resolve url link to the image file.
Instead of placing same code in all files you can simply place it in master pages within ...tag. In all pages that will be reflected.

Javascripts in ASP.NET

               In asp.net we use javascript as same as in html. That will work fine. But using inside web user controls , instead of calling textbox and other controls directly, call the control as document.getElementById('<%=txtname.ClientID%>') . This will make that control to fetch correct value. Here in asp.net every object will have client id. Javascript will search for that particular client id in that controls.