Posts

Showing posts from June, 2013

Simple Model View Presenter Demo in C#

Image
Model View Presenter is a software approach pattern conceived as derivative of Model View Controller. What is Model? Model is a domain level or business level object. A model accommodates application data and provides behaviours to systematically access it. It should be independent, it should not have any association with user interface issues. So we can reuse the same model for different type of UI level applications. What is View? A View is a windowpane for showing the model data or elements to the application users. Model does not have direct link to the views. View know about their Models, but not the other way around. What is Presenter? Presenter will address the user input and use this to manipulate the model data. View will pass the user input actions to the Presenter for interpretation. Presenter will act on the received data from View and communicate with Model and produce results to the View. Okay now we are going to do a simple Demo to get hand on experience a...

Recursive Method to find control in complex page

Image
Today I'm going to show you a simple method to find a control (Textbox, Dropdown, Label) in a complex Page where default findControl method is not useful. Using this method you can identify the control easily and it's recursive method so the LOC is few. enjoy it. /// <summary> /// Find a control when Root control is known /// </summary> /// <param name="rootControl">Instance of the Root control</param> /// <param name="controlToFind">Name of the control to find</param> /// <returns></returns> private Control FindControl(Control rootControl, string controlToFind) { return rootControl.ID == controlToFind ? rootControl : (from Control control in rootControl.Controls select this.FindControl(control, controlToFind)).FirstOrDefault(t => t != null); } hmmm That's all.simple huh. happy coding and have a nice day.

Deep dive into OpenXML Part 1

Image
Okay guys today I'm going to say about the Excel manipulation using the OpenXML. you can do various things using OpenXML and here I'm going to explain most important things you should know about OpenXML when comes to the Excel programming. okay then let's start. First of all go to visual studio and create a console Application. To work with OpenXML you need to add several Dlls to your project. so after you create the project then go to project reference and add following dlls.        1. DocumentFormat.OpenXml. you can download this dll from here .        2. WindowsBase okay now we are half there. now our project is ready to welcome the OpenXML. so let start coding and make some application.       so now we need to add a class called ExcelUtilities to put our common method which we are going to  use every time. so let's go and create that class and add those common methods and don't forget to add these namespaces t...

How to overcome System.IO.Packaging.Package error while working with OpenXML SDK

Image
Hi, Okay this error will occur when you try to work with OpenXML SDK 2. Now You are added OpenXML dll and added OpenXML related to namespaces to the class...and you are good to build the solution. when you press the Build (F5) Button, Visual studio shows you a crazy error. and most of you try to add System.IO namespace to the solution or calss to overcome this. To be honest in first time I also tried. he he heeeee. but that's not the solution for this error. When you are working with OpenXML namespace this is a very common error and It's not a very complex error. you can fix this problem very easily. so what you have to do is go to project's reference area in the solution explorer and right click to add a new reference then in the reference browser dialog select and add WindowsBase.dll in Framework Assemblies Tab. Okay that's all. press Build (F5) Button again. if you did other things correctly (joking) It'll build smoothly. Have a nice day folks. 

LINQ for Beginners - Part 1

Image
Now I'm going to talk about another Important thing you should learn about when you are dealing with C# language. It's Language Integrated Query (LINQ). here is some point you should know before go to the coding segment. LINQ is set of C# 3.0 language features and framework features for writing  structured type-safety queries over local object collections and remote data sources  LINQ enable query any collection Implementing IEnumerable<>, whether an Array, ArrayList, List or XML Dom or Database Table  LINQ lives under System.LINQ and System.LINQ.Expression namespaces. The basic units of data in LINQ are sequences and elements  A sequence is any object that implements the generic IEnumerable interface and an element is each item in the sequence. This is called a local sequence                     string[] names ={"sam", "John"}; A Query operator is a method that transforms a sequence. A ...