Posts

Showing posts with the label C#

MS Code Conversion Tools

Now-a-days, I’ve been exploring much thru VB.NET programming. As being a programmer for more than 3 years, I’ve found difficulties in VB.NET programming towards writing the right syntax. But all these days, I used to think that there are online code conversion tools available to make my life easy. But I were found mistaken with the widely available code conversion tools. There are 2 tools that are widely used by the industry. One is from Telerik and the other is from Developer fusion . These both do the work till the maximum extent, but couldn’t handle the situation of event delegates and lambda expressions. The main problem is this with many of the free tools, they would not be having that intelligence provided for free. Surprisingly,  Developer fusion doesn’t provide any paid services. Telerik didn’t indicate that there is a paid version for the same. Hence, my work become more troublesome. While planning to post a query at the MSDN Forums for VB.NET lambda expressions as well...

Application Designing Stages using SOA : SOA in Short

In our recent project, we are following SOA principles. Everyone think of SOA based applications, but they would have their own means applied for it. In this post, I’m too trying to convey my meaning and how we found it is profitable for both, the client and the development teams. Our SOA is spanned across 6 stages. Every stage has it’s own importance as well as documentation involved. Before we proceed further, we are not just working on the water fall model, but we also follow the Agile Methodologies. It really and clearly mentioned in every methodology that documentation is mandatory. But again, every methodology has it’s own recommendation towards documentation. Instead of talk / debate / write more about the Methodologies (vs) Documentation , let me go into the SOA Phases that worked for our current project. Stage 1: Service Candidates At this stage, we identify the business from very high level and understand the candidates that play vital role in serving the business as Servi...

Coding Standards – Cumulative information

I was reading some C# related stuff and came across of this post . I recollect that some time back I’ve written a post about coding guidelines. My post is more in the same lines that of Amazedsaint’s conclusion. But he did a decent work in collecting all the currently available coding standards guides into one location. After going thru all the documents, I came to a conclusion that all the documents are highlighting their major part in the naming conventions rather giving attention at the actual standards that matter for the effective coding. Every developer / expert writes about their experience in coding and convey that in certain situations, certain coding practices makes a big sense. Having reading all such posts and looking at the current collection by Amazedsaint, I now decided to collect such best practice posts and present them here. This is my next TODO.  Until such time, I start collecting, here is a sample post about Javascript SWITCH case and how it can be converte...

Differed Execution (vs) Immediate execution in LINQ

Recently while understanding LINQ, many things unfurled from MSDN. The main theme of .NET is lazy binding (or) lazy loading. And it is evolving in all the ways within the .net Framework. I recollect in one of my previous posts about the mainly concentrated theme for every version that is released. I could be wrong from the insider perspective, but what I’ve observed is what I’ve written. Anyhow, coming back to the main purpose of this post, which is all about the lazy loading and the point behind various execution mechanisms that are available within LINQ. Before I proceed further, one point is very certain that, choosing LINQ is costlier from the point of “Response Time” from DB to any connected system. This statement is true when compared the LINQ with any traditional mechanism of database connectivity. Traditionally, every developer writes code with Connection object for connecting to the Data Store and then disposes the connection. This method can be by various objects that are ...

Prevent user input for Number / Chars / etc

  Today, I’ve come across of a requirement within a windows application to suppress the user input and allow only integers for a text box. Currently am working with .net framework 4.0 and I use C# as programming language. Before I search the web for any code samples, MSDN is my primary source for understanding the control behavior as well as the different events that are associated. In most cases MSDN would have proper help text and meaningful examples. For my requirement, eliminate user input if it is other than integer, I found a link from MSDN. The given example is inappropriate for eliminating the key input. The given example doesn’t work for you, if your interest is to prevent the user to input anything other than the numbers. I’ve tried and came up with a simple workout for preventing the user to input other than numbers. Here is my code, please comment and revise if it can be more simplified. Step 1: We need a small reusable function as mentioned below. bool IsDigitInput( ...

Creating a Secure Base Page class for ASP.NET Pages

Every web application developed using .NET as application framework needs authentication as well as authorization. ASP.NET provides 2 types of authentication providers for the web applications, namely Windows Authentication Provider and Forms Authentication Provider . Am not going to discuss these types and various modes of authentication. But am going to write about how one can implement a code to secure their web pages. And specially if these pages require some kind of user login is a mandatory. First, you create any page that is supposed to be secured, say for instance AccountDetails.aspx. This page by default takes the inheritance from System.Web.UI. Page class. Now that you have created the page, it is the time for you to induce the security for this page. So add a new class to your application and name that as SecureBasePage .CS. This class is now inherited from System.Web.UI. Page class. The code would look like below public class SecureBasePage : System.Web.UI. Page { pub...

Month Name from Month number

Today, there was a requirement to show the month name in a text box. There are two forms that we have to show, depending on the user choice. The choices being the full name of the month as well as short name. Something similar to that of “October” for full name and “Oct” for short name. We know that we get the month number from DateTime object. This DateTime object has many properties that are directly associated to show the different parameters of Date and Time of the day. But now, for our requirement, you can get the full name of the month with the help of the Globalization object. That is too complicated. The simple method is to use the ToString() with the format that is required. DateTime .Now.ToString( "MMMM" ) Give you full name DateTime .Now.ToString( "MMM" ) returns you short name as required How is this?

Copy binary table data from diff servers

Today, before we start an internal demo of our project, we realized that, on a particular table there is no data in the QA server. We have every thing ready, but no the sample data. We just can’t create an insert script from the table and execute the script there, because, there is a column which is binary type. When we generate the script, the binary data type is not able to populate. Then we are struck with a big question of how to transfer the data between servers. Let me explain you much in detail about our infra structure. We have a dev DB server for our internal development hosted on 192.168.2.10 <<local ip address; for our convenience >> We have a test bed for our application and IIS installed on it, let’s say this is 192.168.3.10 , which is altogether a different network. And this IIS is connecting to a TestDB Server (let’s say it is hosted on 192.168.3.20 ), where we migrate our DB scripts to create the database / tables / stored procedure / user defined functio...

Multiple Validation Groups limitation

Image
Within the single form it is evident that you can have multiple validation groups. To explain more, it is good to throw some light on such requirement. In our current project we have the following requirement. If you observe this screenshot, the “Request a Quote” box is repeated. And on click of “Add More” button, one more “Request a Quote” would be added to the screen. Every time such a box is added, they are generated along with RequiredFieldValidator and adding the ValidationGroup property with the respective item index. In the above case, we have 2 validation groups. Now the problem is about validating the required fields on “Submit” button. If there is only one validation group, you can directly associate the validation group to button with the “ValidationGroup” property. But in this case, we don’t a direct association of single validation group with single button. Hence we need to associate the multiple groups with the submit button, as mentioned below < asp : Button ID =...

4 Checkboxes – Some tricky issue

Image
Today, almost more than 4 hrs I'd spent on this issue. Do you want to know what is that? Here is that. I have 4 checkbox elements and I have to do the following conditions Condition 1) Any one check box has to selected Condition 2) If any of the first 2 check boxes are selected, my code should throw an exception when the 3rd check box is selected Condition 3) vice versa for Condition 2 A picture is worth of 1000 words. Here is the actual requirement. Hope you got the actual picture. Now here comes the actual twist. You can do that with simple if conditions, but i thought of implementing this using territory operators using a single if condition. And the condition goes like this.. if (((cbRepair1.Checked || cbCalibration1.Checked ) ? (cbBoth1.Checked) ? false : true : (cbBoth1.Checked || cbOnLine1.Checked) ? true : false )== false ){ throw new Exception ( "Duplicate selection .." ); } It took me almost more than 4 hrs. Isn’t it funny!!

CheckBoxList validation

Within our current project, we faced a requirement such that there are multiple checkboxes and the user is required to select any one of them (at least one of them). So as there are multiple checkboxes, decided to go with CheckBoxList control. Now the problem is that, we need to show a error message if the user is not selected any one of them. The problem also extends not just there, but the display text should be culture specific. So the story started long after I've written this post. But editing this entire post due to a simple non supportive feature by IE. I’ll come to that point little later, let me first detail the requirement and solution. There is one more solution for this unsupported error. Please read thru the post. For all the client side validations, it is widely known that validation controls supported by ASP.NET framework are popularly used. But these controls can’t handle the CheckBoxList. Hence the following solution. Step 1: Place your CheckBoxList control in a...

Mix: UK 07 Vedios

For all those who didn't attend the Mix at UK during Sep 07, here is a good news. The good news is not only for those who didn't attend the MIX, but for all the technology lovers as well as persons who are passionate about latest technology happenings. The two day event is now available for offline viewing at their website. Here is the link that give you the download of all the videos of all the sessions that happened. Isn't nice for all of us, who missed the event and who couldn't afford to attend the event. It's time to download and view them offline. Am going to download all the events, if any of you doesn't have the i-net connectivity or by any issue, could not download these videos, drop me a mail at DSKCHECK at MSN dot COM Catch you later..

C# 3.0 - What's New : {Implicit}-Part1

Recent development in my technical life is that, started working out with Orcas Beta 2. So, thought to blog about the latest happenings with C# language. The idea emerged to start a series of posts related to C# new features. This is the first of ever such kind of blogging specific to a topic. C# 3.0 has many-a-new features. To start with, let me take a concept of Implicitly Typed Variables . Implicitly Typed Variables In the good old days, the developer has to worry about the type of the variable. Say for instance, whether to use long or double for a counter. Here all that we observe is that the language that is built upon is the type specific. Hence forth the developer is not required to define the type of the variable at the time of declaration, but it is the task of the compiler to decide what type of the object the variable is. All that the developer has to do is that, use the var keyword while declaring the variable, similar to that of JScript or Visual Ba...

What is LINQ & Lambda Expressions

LINQ By definition Linq is Language Integrated Query. That's not the concept of this post. From my understanding and experience with LINQ as well as SQL programming, i would like to make a point. Most of the ideas that are in air about LINQ is an extension to the Structured Query Language, ie., SQL. In other words it is spelled as a kind of influence by Microsoft to the SQL. Having mentioned the misconception from the people, let me correct with my understanding of LINQ is all about Reflection . So it is not about any kind of Database related query language. Lambda Expressions By definition from MSDN, they are the extension for the Anonymous methods from C# 2.0. In reality they can be interpreted as anonymous functions, such as from C# 3.0 feature some thing similar to FUNC<>. In other words, lambda expressions are nothing but the inline expressions . And the function body of the FUNC goes on the right hand side of <>