WCF Hands on Lab – Csharp Corner Delhi Chapter event : A Very Successful day

Hi All,

CSharp corner Delhi Chapter had a very successfully event in Noida on 18th may 2013 and attended by around 100 attendees . In this event we had a full day hands on lab on WCF and continued more than 10 hours. I talked on Exception and Error Handling in WCF and every body enjoyed the day. The topics that we covered are

  1. Lab 1:  Write First WCF Service by Dhananjay Kumar
  2. Lab 2:  Working with Data Contract by Dhananjay Kumar
  3. Lab 3:  Working with Fault and Exception by Brij Bhushan Mishra
  4. Lab 4: Security in Service and Instance management in WCF by Suchit Khanna

You can find the the demo that we did in attachment.

First time in in my life, I found that more that 95% attendees stayed till end of event. This was fantastic and gave us more energy till end and organize more such event in future as well.

Few pics of the event are

946384_10201256436955888_1465523355_n3431897_10201256430075716_925447643_n923064_10201256467076641_108659269_n260333_10201256402715032_383110347_n971456_10201256482797034_1990173058_n
Very attentive Attendees

428049_10201256575199344_206421414_n

The next event is planned on 22nd June. Other details will be published on ob C# Corner

Thanks all for joining the event. Hope to see you all in next event.

Cheers,
Brij

Visual Studio 2012 and .NET 4.5 Expert Development Cookbook : A Review

In this post, I am going to review a Book Titled as Visual Studio 2012 and .NET 4.5 Expert Development Cookbook and written by Abhishek Sur. This book got published recently and I am feeling really good to review this book.

6709EN

Review

As the Title of the book states, this book covers about Visual Studio and most of the topics that are widely used amongst .NET developers under the umbrella of .NET.

The book starts with Visual Studio 2012 IDE features and this chapters discusses most of the features that are available since beginning and introduced with the new version. I can assure you that Visual Studio IDE provides lots of features that are very helpful in our day to day development and almost half of these features is not used by most of us. After reading this chapter, you’ll feel that now your day to day coding become easy and more manageable.

Second chapter covers the insights of .NET programs and Memory Management. This chapters discusses from writing the code, compilation, binaries , the execution  in detail. If you want to know the little insight that How all these compilation, packages and execution takes place, you’ll really like this chapter.

Third chapter talks about Asynchronous programming in detail. Most of developer either does not write the asynchronous programs or do not follow the best practices. This chapters covers all the aspects of asynchronous programming with proper code snippets. it also suggests that in which scenario what pattern one should follow.

Fourth Chapter covers the changes that took place in ASP.NET 4.5 and covers the new changes with examples. It also includes the IDE changes that helps writing ASP.NET 4.5 application. In all, it gives a quick hands on for ASP.NET 4.5

Fifth Chapter covers the changes in WPF and talks the topic like MVVM pattern, Ribbon User Interface and WorkEvent pattern in WPF with examples. So if have worked on WPF you’ll get to know the enhancements made in it.

Sixth Chapter talks about Touch-sensitive device Applications in Windows 8. This is relatively new topic and covers about different flavors of writing windows 8 apps.  In all, after reading this chapter you’ll get practical knowledge on writing Windows 8 apps and app life cycle.

Last (Seventh) Chapter and it is also the chapter covers about Communications and Sharing about Windows 8 apps. It is relatively advance topic and talks about the communication between multiple windows 8 apps and working network enable windows 8 apps. After getting basics of Windows 8 apps in last chapter, this covers advance topics wit examples.

One thing that I see as a flaw considering a common developers that most of the chapters are little lengthy includes more than 50 pages and cover lots of things. If you are book lover then it should not be an issue but for normal developer, you start a chapter and keep reading little long to complete a chapter.

At last, I would highly recommend this book to those who want to learn the changes took place in .NET 4.5 including IDE and other various technologies like ASP.NET, WPF , Windows 8 apps. This book includes many code snippets and example so that once gets practical knowledge with diagrams whenever required. As this books covers most of the topics so it focuses mainly the changes in .NET 4.5 and gives brief about the earlier existing feature. So it’s better if you have earlier working knowledge on the technologies that it discusses.

You can buy this book from the blow link

http://www.packtpub.com/visual-studio-11-and-dotnet-4-5-expert-development-cookbook/book

Thanks to you all :)

Join me at C# Corner Delhi Chapter event

Hi All,

C# Corner Delhi Chapter is organizing a full day event in Noida on 18th May 2013. The theme of the day is WCF and there will be full day Hands on Lab on various topics on WCF. I’ll be speaking on few topics there.

To get the event details Click Here

So if you want practical oriented learning on WCF, Join us in time and grab your seat.

Thanks,

Brij

Working with WebGrid using AJAX : ASP.NET MVC

I am going to write another post on ASP.NET MVC. Here in this post, I’ll be talking about WebGrid. If you have read my last post ( to go Click here), I had a main View and many Partial Views that are integrated with main View. Every partial view was independent and we loaded each partial view via jQuery AJAX call.

I got another requirement to have one more partial view on that page which also shows the data similar to other controls but here the requirement was to provide a specific feature Sorting. So as I was looking for various options for it. First I thought to making my custom partial view which provides the desired behavior. But I thought of using any existing control.

Later I found, that a class WebGrid is provided and available under namespace System.Web.Helpers, that renders the data in HTML table element and also provide feature like sorting, paging etc. I required sorting feature so I decided to use it and found fairly simple to write the code for it.

The code at my partial view is as

@model IList
@{
    WebGrid grid = new WebGrid(Model);
}

@grid.GetHtml( columns:grid.Columns(
	        grid.Column("ProductName", "Product Name"),
		grid.Column("UnitPrice", "Unit Price"),
		grid.Column("SaleDate", "Sale Date"),
                grid.Column("SoldQuantity", "Sold Quantity"),
		grid.Column("SalesPersonName", "Sales Man")
     )
 )

If we see the above code, we have created am instance of WebGrid and gave the model in the constructor itself. So that it can bind with the model. Then I have defined the column in the WebGrid that I want to show on the page.

I have just added this control to my sample that I created in last post. (I’ll attach the complete code) and wrote my Client side to load the control as

        $.ajax({
            url: '/Home/GetSalesDetails',
            contentType: 'application/html; charset=utf-8',
            type: 'GET',
            dataType: 'html'

        })
       .success(function (result) {

           $('#dvSalesDetailsLoader').hide();
           $('#dvSalesdetails').show();
           $('#dvSalesdetails').html(result);
       })
       .error(function (xhr, status) {
           alert(status);
       })

Apart from this  I created the model class for SalesDetails and corresponding Controller method.

Here if we see I am again using jQuery ajax to load the control and assigning the returned HTML to the corresponding div.

I have shown the specific code that is required for this post. The complete code is attached.

When I ran the code, it worked perfectly as

Full Page

You can see the newly added control (Sales Details in the encircled area), It displays the data perfectly. But when I clicked on Unit Price column header to sort, I got shocked because it got displayed as

After sorting

But when I gave it a thought, I understood the problem. After clicking on Unit Price the page did not maintained the state of the page and after the refresh only control that I clicked got available on the refreshed page.

But if you see the column is sorted and if check the URL grid itself send the sort column name and sort direction as query string.

I had to refresh the only that area of the page that contains the last control. So I did some research on it and made changes and finally got succeeded. For that I had to made the change in the code.

First I updated the code where I instantiated the WebGrid class in the Partial View as

WebGrid grid = new WebGrid(Model, ajaxUpdateCallback: "SalesDetailsUpdate", ajaxUpdateContainerId: "dvSalesdetails");

Here, if you see I have assigned two more properties; one is ajaxUpdateContainerId which is assigned with the div id where the control’s rendered HTML is displayed. And another ajaxUpdateCallback this is assigned a Client side method that is fired on every refresh initiated from the grid. So the Client side method is simple and is as

        function SalesDetailsUpdate(result) {
            $('#dvSalesdetails').html(result);
        }

Here I am just putting the result in the defined div. Now when I ran the code, It started working fine and the now only the grid
is updating on sorting.

Hope you have enjoyed this post.

Thanks,
Brij

Loading the partial views using Ajax for Beginners

Last week, I was working on an application that was made in ASP.NET MVC3. Earlier I thought of using ASP.NET MVC 4 but didn’t find any specific feature of ASP.NET MVC4 so moved ahead with ASP.NET MVC3 version.

So as I worked on a POC using with ASP.NET MVC initial version long back so I was excited working on it. I had to display multiple user controls and the data of these controls was getting picked up from multiple sources. So I thought of loading the controls via ajax call individually. So let me share my understanding with a example. I have created a sample application in ASP.NET MVC3. I created a main View (called here HomePage.cshtml)and created two Partial Views (_ProductDetails.cstml and _UserDetails.cshtml) that will be displayed. So I’ll show you how easily we can load these controls via Ajax. It will make page more intuitive and seamless to users.

I am showing simple data in these controls and and one control display the details of the users and other control displays product details. For this, I have created two models User and Product.

While we can load each controls easily via jQuery ajax. For this jQuery must be included in the on the View. By default it is included in the __Layout.cshtml. It works as a master layout of the page but if you are not using it in your View then include jQuery file specifically. So my HomePage.cshtml looks like

HomePage

and my Client side code is as

<script type="text/javascript">// <![CDATA[
        $.ajax({
            url: '/Home/GetUserDetails',
            contentType: 'application/html; charset=utf-8',
            type: 'GET',
            dataType: 'html'

        })
        .success(function (result) {
           $('#dvUserdetails').show();
            $('#dvUserdetails').html(result);
        })
        .error(function (xhr, status) {
            alert(status);
        })

        $.ajax({
            url: '/Home/GetProductDetails',
            contentType: 'application/html; charset=utf-8',
            type: 'GET',
            dataType: 'html'

        })
       .success(function (result) {
           $('#dvProductDetails').show();
           $('#dvProductDetails').html(result);
       })
       .error(function (xhr, status) {
           alert(status);
       })

// ]]></script>

So here you can see as each control is loaded individually. For each control, I have defined a method in Controller and that method is called via Ajax . When result is returned from the ajax call successfully that success event gets fired. Here I am setting the returned HTML in a div and displaying it.

Also here we can easily pass the parameter to the controller methods if we want, via url itself.

Now when page load it fires two ajax calls fired individually and when the result is returned then the control is displayed. In the meantime, user may see blank screen, so here we can show some loader image and once result is returned and we hide it display the control in success event.

I have included the sample in attachment. (I have created this demo using Visual Studio 2012). When we’ll run the application, it looks like

AfterRunning

Hope you have enjoyed.

Thanks,
Brij

wsdl ans Svcutil : Add Web Service Reference in VS 2010/2012

Hi all,

This is going to be a small post and I am going to share one problem that I faced few days back.

I received a service a web service URL that was written in some different technology other than .NET and I added the the reference of it using add service reference but when I compiled that application,I received many build errors.

Then I just realized that I am using Add service reference option and it uses svcutil.exe to create the proxy. As we know this utility was introduced with WCF and works well for WCF  services.

I recalled the way the way we used to write the WCF services like writing different contracts like service contract, message contract and message contract and the way we write in asmx web services is totally different. The assemblies are different as well. So I tried to find where I can get the option to Add Web Reference ( Although I had the option to use the command line utility). I found it here

Right Click on the project -> add service reference

first

Click advanced as above

second

Now Click on Add Web Service Reference.

third

You can remember the above screen. We used it a lot while working with VS2005. The above one uses the wsdl.exe to generate the proxy from the wsdl.

After using this utility my application started working. Svcutil.exe is a sophisticated tool (provides many options and other features as well) and it’s generates the proxy in different way to create it. For details refer the links below

For wsdl.exe

http://msdn.microsoft.com/en-us/library/7h3ystb6%28VS.71%29.aspx

and for Svcutil.exe

http://msdn.microsoft.com/en-us/library/aa347733.aspx

Hope that helps.

Happy Coding,
Brij

Join me at Delhi User Group April Meetup

Hello Friends,

Delhi User Group has planned event planned on 20th April (Saturday) and all professional developers invited.

I’ll be speaking on T-SQL features in SQL 2012. So if you are a SQL dev and excited to learn the SQL 2012, Join us on coming 20th April.
There are many other Talks are planned of PowerShell,  SQL and .NET, you will enjoy. This is free event and will be taking place at Microsoft Office, Gurgaon.

Register for the event here.

For complete details about the event click here

I am excited to see you at event and so if this topics interests you, Join the event and learn!!

Thanks,
Brij

Follow

Get every new post delivered to your Inbox.

Join 85 other followers