Friday, July 29, 2011

Call Server Side Method using ajax JQuery in ASP .Net

When I have started work on ajax. I used to passed parameters in the url while calling server side method through ajax call. But problem was that when we send value with Hash(#). It was not sending whole value to server side.It was sending only value before hash(#). Than I have found another way to send parameter to sever side.We can directly call server side method and pass parameter through ajax call.

Write this function on client side.

function SendServer()

// var sVal = $("#txtName").val();

var sVal = "Red";

type: "POST",
url: "Customer.aspx/GetValue",
data: "{param1: " + "'" + sVal + "'" + " }",
//data: "{'param1': 1}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg)

// $('#Rslt').text(msg);
// $('#Rslt').text("Some error has been occurred.");

And on server side define a static method with WebMethod attribute. Add a name space System.Web.Services

public static string GetValue(string param1)
return "Call Server Side method through ajax call and pass parameter :" + param1;

One thing that you have to remember parameter name should be same on both side.Just like the above example I have used param1 both side.

You can download the sample code from here.

Friday, July 22, 2011

Search is not working in Windows XP

Today I have encountered search problem in Windows XP. I was trying to find a string in a folder which contains files with extension .xhtml. But could not while file was exist inside folder with searched text.

Actually windows has some specified extension for which it do the search. If you want to add some more extension follow these step.

1) Go to Run.
3) Expand the key and search your desired extension here.
If it is not here create one the name it like .xhtml,.xml,.bak whatever required
4) Create a subkey and name it PersistentHandler.
5) Double click on Default item in the right side pane.
6) A pop up window will, Copy paste below string in the value filed and close it


7) Reboot the system.

For an Example I have done it for .xhtml file and my registry key is

Windows Registry Editor Version 5.00





You download this file and change your extension in the file it is for .xhtml currently. You can replace .xhtml with your required one. Now just double click on the file and follow the instruction.

Friday, July 15, 2011

Put the dlls in separate directory

In dot net you can put the dlls in separate directory from the exe. You need to add following code in your config file.

<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1" >
<probing privatePath="bin;bin2"/>

privatePath : contains the directory name where put your dll files. It may contain multiple directory name separated by semi colon.

Friday, July 8, 2011

How to create Bookmark in pdf file

How to create bookmark in pdf file using Java Script. In java script we can create a plug-in to create the bookmark in Adobe Acorbat Reader.

To create a book mark in pdf file just download the file


And copy this file at

* Mac: ~/Library/Application Support/Adobe/Acrobat/9.0_x86/JavaScripts (or similar)
* Linux: /home/[User Name]/.adobe/Acrobat/9.0/JavaScripts/
* Windows XP: C:\Documents and Settings\[User Name]\Application Data\Adobe\Acrobat\9.0\JavaScripts (or similar)
* Windows 7 & Vista: C:\Users\[User Name]\AppData\Roaming\Adobe\Acrobat\9.0\JavaScripts

With the help of this file you can create multiple bookmark. Restart the Acrobat Reader and go to View->Bookmark this page.

But if you want to create a single bookmark just like a book. For that download the file.

And copy it on same location.

Restart the Acrobat Reader and go to Tools->Bookmark -> Bookmark this page.

Friday, July 1, 2011

UpdateMode in Update Panel

UpdateMode property in Update Panel.

Why update panel is slow?
Due to Update Mode property of the UpdatePanel. If it is set to Always it will make the whole page slow. Since on each post back each Update Panel content update.

This property plays an important role in performance of ASP .Net page. By default it is Always.

When UpdateMode set to Always?

1) The update panel content is always updated on each post back of page whether it is synchronous call or asynchronous. No matter the control that triggered the post back is inside the update panel or not. Or inside other update panel.
2) If the update panel is inside other update panel. Than when parent will update child always update. No matter child update panel update mode is Always or Conditional.

When UpdateMode set to Conditional?

1) Update Panel content will update only in case of any control that is inside Trigger cause post back.

2) Or if ChildrenASTrigger set to true. Than Update Panel contents update in case of its child cause post back.

3)Or you have called Update method of Update Panel explicitly.

ChildrenAsTrigger property in UpdatePanel
Set it to true to update the content of update panel on post back cause by children control of the update panel. If panel is nested with another update panel. Than parent update panel contents will not update on post back cause by children control of the inner update panel.

By default value of ChildrenASTrigger is true.

You can not set it false with UpdateMode="Always". In that case InvalidOperation Exception thrown during PreRender event.

RenderMode property in UpdatePanel.

There are two possible values for RenderMode one is inline and other one is block. if it is set inline Update Panel convert into span tag. In case of block Update Panel convert into div tag. By default value of RenderMode is div.