Tag | Csharp Posts

While C# is a computer language, Microsoft Visual C# is a programming environment used to create various types of applications, including console, graphical (GUI), XML, databases, and file-based, etc. This web site provides lessons and other topics on using Microsoft Visual C#, any version (Microsoft Visual C# 2005 Express Edition or Microsoft Visual C# Professional). Windows Controls Button Browse for Folder Check Box Checked List Box Color Dialog Combo Box Context Menu Data Grid View Date Picker ...
Very impatient, moderately lazy; I use the keyboard to do whatever I can whether I’m in Visual Studio, navigating the web, or just moving around the O/S. For example, if I need to launch word I’m just going to hit the Windows Key + R and then type WinWord. I use that technique for basically anything I know the application name for…notepad, calc, whatever. If the application name is “too much” for me to type I’ll create a real old-skool bat file and throw it into my C:/Windows/System32/ folder. A ...
I’d like to provide you with a SilverBullet™, a small snippet of Silverlight, a class or namespace hidden in the silverlight .NET framework, to help you out in times of need. It’s not to learn, but something to keep in your pocket. Just remember it’s there and you’re safe. The System.Json namespace provides support for Javascript Object Notation or JSON. By using the classes in this namespace you are able to use Json objects in your C# or VB code. These object are often used in JavaScript and to ...
MVC seems all the rage these days. And while there are many good things it brings to the table, it seams it takes us a step back in terms of I18N. For instance, if you want to use the special aspx attribute meta:resourceKey="foo", you won't always be able to do so. The following would work fine: 1: <asp:Label runat="server" ID="_QueryPrompt" Text="Enter Query" meta:resourcekey="_QueryPro... />&nbsp; But we're out of luck with buttons: 1: <asp:Button runat="server" ID="btn" Text="Run" ...
We've all been told to think of a dynamic object as a regular object but with dynamic behavior. Kevin Hazzard peeked behind the curtain to show that the compiler is actually doing a lot with that keyword; it isn't just an object. It does change the type to an object, but then it builds CallSites everywhere that object is referenced. These CallSites handle the calls to the dynamic language runtime. That's great, but we have an object. How does a consumer of your class library know that a property ...
Often when creating web applications, it’s common for us to want to submit or post forms to the server by using a hyperlink rather than an HTML submit button. It might be visually more appealing/consistent or whatever your reason might be to have your buttons look like this: The Cancel button is easy because we can just use a normal Hmtl.ActionLink helper to redirect to whatever our cancel page is. But what to do for the Save link given that we don’t have anything in MVC out of the box that is analogous ...
Last month (May 2009) Microsoft has released its first beta for Visual Studio Team System 2010 and Team Foundation Server 2010 release, two of the most waited and wanted tools in developer community. From my point of view these two releases are going to be one of the most historical releases, as lots of really cool stuffs has been added with respect to the last version. However, as the Beta 1 releases are pretty infant, there are very limited resources available in the web and community, so I just ...
Introduction In an earlier article I explained how to use .NET assemblies in php. This concept is the basis of the image generation as used in my entry for the WinPHP challenge. Because the user is in control of selection colors, all images used throughout the weblog need to be generated. Php provides a number of graphical functions, but none is capable of creating rounded corners an gradients with ease. Everything has to be done by hand. WPF on the other hand uses xaml which supports everything ...
I’m currently using context/specification style tests. While I think frameworks like J.P.Boodhoo’s are beautiful, I prefer something that works with ReSharper, TD.NET and CI without extra hurdles. I also want something my team, with limited exposure to *Unit frameworks, can easily pick up. I’d prefer not to have the ceremony and misleading terminology of “Test” attributes, but its a trade-off I’m willing to make to more easily to integrate with team members and third party tools. I put my testing ...
The blog engine I’m writing for the WinPHP Challenge is really getting shape. At certain points in the application I would like to send an email. Luckily SMTP is supported by IIS. Here’s a small how-to to get it up and running and send an email from your php app using IIS. Setting Up and Configuring IIS Start by going to the ServerManager on you Server. Most often this is the server you’ll be running your php website on. Go to Add features in the Features summary section. Check SMTP Services in the ...
I was playing around with converting some HQL and Criteria queries to LINQ, and the result is pretty slick:All I had to do was reference NHibernate.Linq and I went from: public IList<Stay> GetCurrentStays() { string hql = @"FROM Stay WHERE CheckinDate <= :now AND (CheckoutDate IS NULL OR CheckoutDate >= :now)"; var query = getQuery(hql); query.SetDateTime("now", DateTime.Now); return query.List<Stay>(); } to: public IList<Stay> GetCurrentStays() { var query = from stay in ...
Introduction After a short sojourn with the Visual Studio 2010 Beta, I’m back with the next part. Pop quiz – can you run Visual Studio Team Foundation and Visual Studio Professional without Team Suite? Well some wit told a client you could not – so I spent some of the Bank Holiday proving otherwise – Another article there on setting it up, but in general it was incredibly easy for a server app! Anyway I digress back to the subject at hand – hosting a Silverlight Application in an Azure Application. ...
While working with a test team, today, we were doing incremental builds of a Compact Framework application. We wanted to display the build time of each release of software, so that the test team could be sure we were all using the current version. This tiny bit of code achieves just that. public static DateTime BuildTime() { Assembly assembly = Assembly.GetExecutingAssemb... string filename = System.Reflection.Assembly.... FileInfo info = new FileInfo(filename); ...
At Lansing GiveCamp I was chosen to lead a team tasked with creating a guest registration system for Ronald McDonald House of Mid-Michigan. Ronald McDonald House wanted to get off their current system, paper, to streamline their processes and report on their data. The event started around 7:00PM on Friday and ended with 3:00PM on Sunday. That’s 44 hours. At first it seemed too simple and I wondered if Microsoft Access wouldn’t have been sufficient for their needs. That is until Jay Harris met with ...
Events are a critical component in Object Oriented programming. Whether they originate from user interaction or code logic, events are at the heart of what makes your application dynamic. Thanks to the advancement in both Java and .Net over the years, the event-driven paradigm has become possible on the web with the advent of JSF (Java Server Faces) and ASP.NET. Both of these technologies support the event-driven model allowing developers to take adantage of the "publisher/subscriber" pattern. There ...
This is a very short post. so bear with me. SELECT * FROM Northwind..Orders ORDER BY NEWID()The Magic here is NewID() Flickr Tags: NewID(), Random Records in MSSQL BuzzNet Tags: NewID(), Random Records in MSSQL Technorati Tags: NewID(), Random Records in MSSQL del.icio.us Tags: NewID(), Random Records in MSSQL IceRocket Tags: NewID(), Random Records in MSSQL LiveJournal Tags: NewID(), Random Records in MSSQL 43 Things Tags: NewID(), Random Records in MSSQL ...
To those whom love Commerce Server 2007 as much as I do. Here is a little script to help you determine the Service Pack level of each database. use MSCS_Admin select s_PropertyName, s_Value From dbo.resourceProps This will return multiple values. This is helpful in knowing if you have Commerce Server 2007 installed correctly as well as helping you to identify the correct service pack upgrade number per database. SP1 Transaction Database = 7.0 Transaction Config Database = 7.0 Product Catalog Database ...
This is a topic that is near and dear to me. Readability is about being able to understand the code. Maybe the word should be “Understandability”, but that word suffers of the exact same thing it describes ;-) Anyway, compare these two lines, and tell me what line you understand fastest: 1: startDate = new DateTime(2008, 5, 15); 2: startDate = 15.May(2008); This might not seem much, but to me line 2 clearly states the intent of the code, whereas line 1 makes me think. I don’t want to think about ...
Introduction For my entry for the WinPHP challenge, my personal Blog Engine “BlogSnor”, I wanted to make use of Ajax to retrieve posts, comments, color data and more from the server. I’ve used Microsoft Ajax in ASP.NET before, so why not try that in PHP too. Here’s how… Installing For the simplicity of this tutorial I make the assumption you have php 5.2 or higher running in iis7 and that your localhost points to c:/wwwroot/inetpub. (If you have not, and you have questions about this, just send me ...
Search Engine Optimization guides, recommends to have one version of a URL of the same content. Search engines may pickup www and non-www versions of URL as 2 separate URLs, i.e. http://xyz.com/page1 may be considered different to http://www.xyz.com/page1. It is a good idea to pick on of these URLs as preferred and use 301 redirects to send traffic from the other URLS to the preferred URL. Today we will pickup www version of URL as our preferred URL and look at how we can redirect the non-www version ...
Here is one way to have data load only when a TabPanel is clicked. In my example I have an aspx page with a TabContainer, two TabPanels both with their own ObjectDataSources that fill GridViews. The first tab’s ObjectDataSource and GridView will run on the page load and that is fine since it would be the first thing a user sees. The overall idea is to have the ObjectDataSource for the second tab to not run on the page load and then have the GridView on the second tab databind only when the tab is ...
Um so you know its your dream to use windows server 2003/2008 as your desktop Operating system right? So most of you just said no. However for the small amount that might just be curious here is a little script to stop installed server applications built into these server installs. @echo off :start set /p _input="Server? [y/n]" if %_input% equ y ( echo Starting server services… sc start HTTPFilter REM HTTP SSL sc start IISADMIN REM IIS Admin sc start lanmanserver REM Server sc start MSSQLSERVER REM ...
[Warning – this is shamelessly taken from the documentation but I felt it deserved a wider viewing] Yesterday I delivered a session on the new parallel capabilities of .NET 4.0 (see slides and links). I also managed to slip in a little section at the end on Axum and Concurrent Basic. These two programming languages are nothing to do with .NET 4.0 but are very interesting if you care about what the future beyond .NET 4.0 might bring for parallel development on Windows. Axum is available for download ...
If you have had a chance to look at the downloadable videos from MIX 09 (http://videos.visitmix.com... then you will have heard that it will soon be possible to develop Azure hosted applications and have good old Transact SQL as a backend! It was in Nigel Ellis’ session on ‘What's New in Microsoft SQL Data Services’ which gives all the details. However as of the time of writing this functionality, while due in the next couple of months, is not yet available. All is not lost. I am going to ...
Introduction: .Net 3.5 has some interesting string functions. I almost admire their usage. Following are those functions that we will be discussing here. String.IsNullOrEmpty() String.Split()(Available from .Net 1.0) String.Join()(Available from .Net 1.0) Reference Links String.IsNullOrEmpty - http://msdn.microsoft.com/e... String.Split() -http://msdn.microsoft.com/... String.Join()-http://msdn.m... ...
Intro For the blog engine I’m writing for the WinPHP contest I needed a place to store data. Because windows specific features need to be used, Microsoft SQL Server is the logic choice. Getting data from the database isn’t as easy as making that choice. The extension that comes with PHP worked well with SQL Server 2005, but failed when running on a Windows Server 2008 machine with SQL Server 2008. Here’s a step-by-step tutorial on how to get it to work on SQL Server 2008. Installation First, download ...
It’s true, I swear. It’s very simple to test if you can (C)reate, (R)ead, (U)pdate and (D)elete objects using NHibernate, and Fluent NHibernate makes it one (fluent) line of code! Suppose we have an Employee object and we want to check that we can CRUD it AND reference to the Company (object) they work for in the mapping. It might look like this: 1: new PersistenceSpecification<... 2: .CheckProperty(x => x.FirstName, "Dave") 3: .CheckProperty(x => x.LastName, "Jones") 4: ...
That’s right, I said it, I’ve been doing it, and I abso-effin-lutely love it. A few months ago my co-worker, Troy, posted a question on Stack Overflow. We were doing integration testing on a project we were working on, and as the object graph grew larger, the code required to test query logic became painful. Since I am a sissy and don’t like pain, Troy asked the question on SO about how we might do it less painfully, and we got this answer, and it totally changed our TDD/BDD lives. The answer came ...
I just found a great post at SQL Tips by Namwar Rizvi - TSQL Function to convert decimal to Hex, Octal or any other base (http://sqltips.wordpress.c... with a great, simple function to convert any integer into a string of characters in any base from 2 through 36. Here it is, the comments include his post text, giving original credit for this algorithm to Itzik Ben-Gan in his book Inside Microsoft SQL Server 2005:TSQL Querying: IF EXISTS ( SELECT * FROM sysobjects WHERE id = OBJECT_ID(N'[dbo].[fn_decTo... ...
NOTA (2009-06-26): Existe una librería oficial de NHibernate Validator con validadores adicionales específicos para ciertos paises, NHibernate.Validator.Specif... (descargar) y ya cuenta con un validador de CUIT. Gracias Fabio Maulo por el dato. La aplicación en la que estoy trabajando está basada en ASP.net MVC y utilizamos Sharp Architecture como base. Sharp Architecture utiliza a su vez NHibernate Validator para la validación de las entidades de negocio por lo que, continuando con el tema del ...
Hey, I just discovered the Whirlwind series on Channel9. Check it out! http://channel9.msdn.com/po... There, you will find videos on C# (CSharp) and Visual Studio ...
So this has taken a bit of investigation. A customers of ours was reporting duplicate transactions arriving from one of our mobile line of business applications. After much head scratching, we’ve uncovered something that I’m sure may help others. Most transactions get fired by the user of the mobile device pressing the right hand soft key i.e : In most cases pressing this soft key, would perform the action then dismiss the form, usually by just setting the DialogResult of our current form. To create ...
DomainUpDown control is one of the new controls available in the Silverlight 3 Toolkit which can be found in Silverlight Toolkit This control Represents a Windows spin box (also known as an up-down control) that displays string values.Help files for the assemblies are downloaded with them by default. This control belongs to the following namepsace. Namespace: System.Windows.Forms Assembly: System.Windows.Forms (in System.Windows.Forms.dll) The control is bound with a datasource collection. One item ...
Etiquetas de Technorati: ASP.net,JQuery,JQuery Validator,Javascript,CUIT Hace tiempo que quiero armar un blog técnico para compartir experiencias y cosas de interes para desarrolladores web y finalmente me decidí. Para el primer post quiero empezar con algo útil que tuve que armar para una aplicación que estamos desarrollando. Se trata de rutinas de validación de CUIT/CUIL (Código Unico de Identificación Tributaria / Laboral de Argentina). Hay varios ejemplos en la web en distintos lenguajes pero ...
If you want to use a Post-build event with folders which contains a space often you get an error like: The system cannot find the file specified. c:\WINDOWS\Microsoft.NET\Fr... error MSB3073: The command "COPY C:\Projekte\_Learning By Doing\EsriDE.QA.StyleCop\bi... "C:\Program Files\Microsoft StyleCop 4.3"" exited with code 1. In my case i used the macro $(TargetPath) in following line which contains indirectly the spaces in "_Learning ...
I needed a quick way to cache some data for a feature I’m currently working on. The scenario is that the user should be able to type ahead and be presented with a list of matching options (AJAX auto complete). This data is coming from an external web service and is exposed via the core API of the application which in turn is exposed over WCF. So for AJAX to be able to get to this data it must talk to the WCF service, but this is not directly possible since cross site scripting is not allowed in the ...
Silverligth 3 is the most awaited release of Microsoft. I found the download’s from the page Silverlight 3. The following are the utlities that can be found in this download page. Silverlight 3 Beta Tools for Visual Studio Microsoft Expression Blend 3 Preview Silverlight Toolkit .NET RIA Services Silverlight 3 Beta Documentation In this list the most attracting one is the RIA services which is making wonders with Silverlight now. I will be discussing about them in the later posts. Now I am going ...
Introduction For my entry in the WinPHP Challenge I need to use some .Net assemblies I wrote a while ago. It wasn’t clear to me how this can be done. Here’s an example on how to do this. In short: First we create an assembly in visual studio, than we sign it, add it to the Global Assembly Cache or GAC and access it using PHP from there. Details Inside visual studio, create a new project. For the purpose of explanation I named the project DotNetTest. Add the following method to the newly created Class1 ...
LINQ is something that has had my full attention ever since it was released. And I’ve been wanting to do something on this blog with LINQ, but never really found the inspiration to do something “special” with it. Up until now. So it occurred to me that there is not (to my knowledge) anything available that allows you to incorporate your LINQ way-of-work with BizTalk. And why not? There are purposes enough to use LINQ in a BizTalk environment, and it doesn’t even have to be rocket science to get there. ...
If you’ve read parts 1, 2 and indeed 3 you’ll know we’ve covered the CRD of CRUD, today we will cover the ‘U’ – updates! Updates are more complex than the other scenario’s we’ve covered so far, but not unmanageable. Also – in fairness this is a very simple update, more complex updates will require more thought (duh!) but this should be a good starting point. Let’s get to it! We’ll start on familiar ground – updating the interface, adding an ‘UpdateCar’ method: [OperationContract] void UpdateCar(Car ...
This is another installment of how to use the ASP.NET ListView and Repeater to generate repeating groups of controls in ASP.NET pages in scenarios which often lead developers to add unnecessary complexity to their pages by resorting to dynamically generated controls. Part 2 demonstrated using the ListView control to maintain the values in a repeating group of textboxes, using a collection of strings as a data source,and allowing the user to add rows as required. This works well for simple scenarios, ...
Today, I was thinking about C# code visualization. I got idea about “flickring” code :) Bellow it is simple Silverlight 3.0 Application for C# code visualization using Filckr as icon source. I want to create Visual Studio add-in for C# visualization using icons for all C# keywords ;) My source code visualization for Flicsharp: ...
You can use the following Free Online Code Converter below just in case you need to convert C# codes to VB.NET or vice versa. Telerik Code Converter Developer Fusion Code Converter Technorati Tags: General ...
I am currently working on a project where we are using the .net web browser control in designer mode. This allows you to use the control as an html editor. There are numerous posts out there on this control. Tim Anderson has a great post on using the html editor control and utilizing allot of its built in features. One feature the control did not have out of the box was the ability to click on an anchor tag when using the editor in design mode. This behavior is in outlook when creating an email in ...
Migrating to C# from C++ or VB? Redgate is offering an ebook of Illustrated C# 2008 by Daniel Solis to help you out. It has a very visual approach, with lots of figures and code samples. Best of all, it's free ...
There is a neat little trick that one has to follow inorder to zip a entire folder into a gzip file. It is essentially a two step process Zip individual files in a folder using TarArchive Zip the tar file using GZip 1: public static string CreateTar(string directoryToCompress, string destPath, string tarFile) 2: { 3: string destDrive = destPath.Substring(0, destPath.IndexOf(@"\") + 1); 4: Directory.SetCurrentDirecto... 5: string tarFilePath = Path.Combine(destPath, tarFile); 6: using (Stream ...
Somebody posted a comment up my blog which contained something along the lines of “and VB .NET does the clever try catch stuff that C# can’t” . That got parked at the back of my brain and I finally went off looking for what this was. Turns out there was a great post on it back in February 2009 on the CLR team blog “Catch, Rethrow and Filters – Why should you care?” . Turns out VB allows us to inspect an exception without affecting state and conditionally decide whether or not to handle the exception. ...
Today I’m going to talk about a feature of C# that has been around since 2.0 (with the introduction of anonymous delegates) but which gets nearly no lip service and, despite the fact that most C# developers have probably used it, they’ve probably used it without thinking about it. This feature is called closure, and it refers to the ability of a nested function to make reference to the surrounding function’s variables. This article will make extensive discussion of how delegates are implemented in ...
Mission: Show elapsed time on a WinfForm in C# thanks to Mahesh Chand original article: http://www.c-sharpcorner.co... 1) add stop & start buttons and a timer control on a web form 2) put code behind the buttons (below), that consumes the StopWatch class (below) public partial class Form1 : Form { static void Main() { Application.Run(new Form1()); } public Form1() { InitializeComponent(); } StopWatch ...
If you’ve read parts 1 and 2 you’ll know we’ve covered the CR of CRUD, today we will cover the ‘D’ – deletions. We’ll need to update our interface to actually provide this functionality: [ServiceContract] public interface ICarsService { [OperationContract] Car GetCar(int id); [OperationContract] void SubmitCar(Car car); [OperationContract] void DeleteCar(int id); } I’ve decided to delete the car via the identifier we created initially, though there is nothing to stop us using a ‘Car’ instance. Anyhews, ...