To install the Ajax Control Toolkit

To install the Ajax Control Toolkit, first download the zip file from http://www.asp.net/ajax/3.5 SP1 Release is here.
Unzip the files into any directory. Give it a name like "AjaxControlToolkit."



Open your Visual Web Developer and right click in the Toolbox area. Select "Add Tab."



Name the tab with something like "Ajax Tookit."



Right click the new tab area, and select "Choose Items..."



This will bring up a dialog box to "Choose Toolbox Items." Select the "Browse" button.



Browse to the directory where you unzipped the Ajax Toolkit files. There is a "SampleWebSite" directory within your "AjaxControlToolkit" directory. Browse to the "Bin" directory within the "SampleWebSite" directory.



Find and select to open the "AjaxControlToolkit.dll" file.



The Choose Toolbox Items dialog will appear, this time with the Ajax Tookit controls selected. Select the "OK" button.


Open or create a web form within your project. Now when you open your toolbox, you will see all of the Ajax Control Toolkit controls, ready for use within your applications.

May your dreams be in ASP.net! More Refernce Click Here

How to Write An SPQuery Using Multiple AND OR Operators

Ok, if you’re like me, writing CAML queries can sometimes make your head hurt. Not because it’s terribly complicated, but because there’s not much useful information out there that demonstrates, with REAL examples, how these should be written. So let’s see if we can clarify this:

Scenario 1

Get me all items in a list WHERE fullName equals the currently logged in user.

1
2
3
4
5
6
7
8
9
10
11
SPWeb web = SPControl.GetContextWeb(Context);

string fullName = web.CurrentUser.Name;

SPQuery oQuery = new SPQuery();

oQuery.Query =
"<Where>" +
"<Eq><FieldRef Name='FullName'/><Value Type='Text'>'" + fullName + "'</Value></Eq>" +
"</Where>" +
"<OrderBy><FieldRef Name='StartTime' Ascending='FALSE'></FieldRef></OrderBy>";

Scenario 2

Get me all items in a list WHERE fullName equals the currently logged in user AND status equals ‘Complete’.

1
2
3
4
5
6
7
8
9
10
11
12
13
SPWeb web = SPControl.GetContextWeb(Context);

string fullName = web.CurrentUser.Name;

SPQuery oQuery = new SPQuery();
oQuery.Query =
"<Where>" +
"<And>" +
"<Eq><FieldRef Name='FullName'/><Value Type='Text'>'" + fullName + "'</Value></Eq>" +
"<Eq><FieldRef Name='Status'/><Value Type='Text'>Complete</Value></Eq>" +
"</And>" +
"</Where>" +
"<OrderBy><FieldRef Name='StartTime' Ascending='FALSE'></FieldRef></OrderBy>";

Scenario 3

Get me all items in a list WHERE fullName equals the currently logged in user AND status equals ‘Complete’ AND manager is James Lane.

This is where it gets a bit tricky. The following example is INCORRECT and will produce an error when run:

This is the correct way to do it:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
SPWeb web = SPControl.GetContextWeb(Context);

string fullName = web.CurrentUser.Name;

SPQuery oQuery = new SPQuery();
oQuery.Query =
"<Where>" +
"<And>" +
"<And>" +
"<Eq><FieldRef Name='FullName'/><Value Type='Text'>'" + fullName + "'</Value></Eq>" +
"<Eq><FieldRef Name='Status'/><Value Type='Text'>Complete</Value></Eq>" +
"</And>" +
"<Eq><FieldRef Name='Manager'/><Value Type='Text'>James Lane</Value></Eq>" +
"</And>" +
"</Where>" +
"<OrderBy><FieldRef Name='StartTime' Ascending='FALSE'></FieldRef></OrderBy>";

Scenario 4

Get me all items WHERE fullName equals the currently logged in user AND status equals ‘Complete’ OR status equals ‘On Hold’.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
SPWeb web = SPControl.GetContextWeb(Context);

string fullName = web.CurrentUser.Name;

SPQuery oQuery = new SPQuery();
oQuery.Query =
"<Where>" +
"<And>" +
"<Eq><FieldRef Name='FullName'/><Value Type='Text'>'" + fullName + "'</Value></Eq>" +
"<Or>" +
"<Eq><FieldRef Name='Status'/><Value Type='Text'>Complete</Value></Eq>" +
"<Eq><FieldRef Name='Status'/><Value Type='Text'>On Hold</Value></Eq>" +
"</Or>" +
"</And>" +
"</Where>" +
"<OrderBy><FieldRef Name='StartTime' Ascending='FALSE'></FieldRef></OrderBy>";

I really do recommend if you’re doing any work with CAML queries that you download the U2U CAML Query Builder 2007. It doesn’t come without it’s issues, for example, doing a query on a list with a column of type Lookup does not always yield the results I would expect, but it’s still quite helpful. I also often find myself changing the Value Type from Lookup to Text but other than that it’s a huge resource when trying to determine if the data is actually in the list or if there is a problem with the query i’ve written.

Any feedback or questions, please drop me a line.

If you have better solution, just tell me !

ASP.NET AJAX 1.0 Source Code Released

As I mentioned last week when ASP.NET AJAX 1.0 shipped, we are publishing the full source code to the ASP.NET AJAX product. This includes the source to the server-side ASP.NET integration (including the UpdatePanel, UpdateProgress, and ScriptManager controls, as well as the source to the Network Serialization code).

The client-side ASP.NET AJAX JavaScript library (which we also call the "Microsoft AJAX Library") is being released under the Microsoft Permissive License (Ms-PL). This grants developers the right to freely customize/modify the library, as well as to redistribute the derivative versions of the JavaScript library for both commercial and non-commercial purposes.

The code for the server-side ASP.NET AJAX 1.0 implementation was released this morning. You can download it here. It is being released under the Microsoft Reference License (Ms-RL). Included with the source code are debugger symbols for the shipped binary, which will allow you to step from your own code into the ASP. NET AJAX library while debugging, with line number and symbol data preserved. Note that the setup installs the source code locally on your machine within the "\Program Files\Microsoft ASP.NET\ASP.NET 2.0 AJAX Extensions\v1.0.61025\Source" directory.

You can also obviously download (and modify) the source code for the ASP.NET AJAX Control Toolkit. It is built as a collaborative CodePlex Project that both Microsoft and non-Microsoft developers contribute code and work on together.

Ajax Trace Console

Ajax Trace Console is a web control to render (only in debug mode) this html code :


<textarea id="TraceConsole">

to AJAX debugging.

Download ASP.NET AJAX PDF Cheat Sheets

Milan Negovan from the http://aspnetresources.com/ site has been working on putting together some really nice PDF "cheat sheets" for the client-JavaScript libraries in ASP.NET AJAX:


These are super handy pages to print out and keep around to quickly find information and code-snippets to use.Milan is making these available completely for free - so definitelydownload them and send him feedback (he is going through and adding them for all the core classes in the client-side AJAX library).

JavaScript, C#, and ExtSharp

Colin Ramsay thinks that JavaScript and C# can be scarily similar as he shows an ExtJS example:


JAVASCRIPT:
  1. var win = new Ext.Window({
  2. title: 'Order Viewer', layout: 'border',
  3. width: 500, height: 500,
  4. modal: true, resizable: false, closable: false, draggable: false,
  5. items: [ frm, lst ]
  6. });
  7. win.on('render', function() {
  8. load(5);
  9. });
  10. win.show();


C#:

  1. var win = new Ext.Window{
  2. Title = "OrderViewer", Layout = Layout.Border,
  3. Width = 100, Height = 200,
  4. Modal = true, Resizable = false, Closable = false, Draggable = false,
  5. Items = new [] { frm, lst }
  6. };
  7. win.Render += delegate {
  8. load(5);
  9. };
  10. win.show();

This works well for ExtJS since it is written in a style that leads itself to this similarity. Colin also points out ExtSharp, a project that lets you write your Ext application in C#:

If you have better solution, just tell me !