Entries Categorized as '.net'

ASP.NET MVC & Threads

Date July 1, 2008

I have a method that handles sending of emails.  I wrote it so that it would run asynchronously, so that it won’t slow down the web app.  It looks like this:

protected static void SendMail(string to, string subject, string body)
{
try
{
using […]

Unit Test Linq to Sql in ASP.Net MVC with Moq

Date April 4, 2008

I have just spent the entire day playing with Moq to unit test an asp.net mvc application I am working with. All I wanted to do is test a “create” method that simply adds a record to the database. So here it goes.
1. I created a Mock Http context to be used by my controller. […]

Ajax with ASP.NET MVC Framework Preview 2

Date March 31, 2008

This is the updated version of the Nikhil’s excellent example on how to use Ajax with ASP.net MVC.
I commented all the changes made in the code and prefixed them with //emad. So just search for //emad and you will see all the changes I made… Here is a quick list of the changes […]

Get Enum Value from String

Date February 20, 2008

Here is a quick tip.  If you have the following Enum
Enum Frequencies
DAILY
WEEKLY
MONTHLY
End Enum

.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, “Courier New”, courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { […]

Improve LINQ Query Performance

Date February 19, 2008

I was writing a small utility for Outlook 2007 and was using LINQ to query Outlook Tasks.  This query was nested within another query.  While debugging, I realized that looping though the query results in my For Each loop was taking too long.
If you have read anything about LINQ, I am sure you already know […]

Fame, Fortune and WCF

Date December 28, 2007

I need your help to bring me fame and fortune.
I wrote an article at code project which was entered for a competition.  The winner gets $10k.  Can you please check it out at http://www.codeproject.com/KB/WCF/myfeedreader.aspx and if you like it, please vote for it.  I can’t win if you don’t vote.  Voting will be closed on […]

Calling the WordPress XMLRPC API from VB.net

Date July 31, 2007

As an example, I will call the getCategories API method.
Add a reference to the XML-RPC.net library.
Create a struct for the return result

Public Structure category
Public categoryId As Object
Public parentId As Object
Public description As Object
Public categoryName As Object
[…]

DataFormatString not working with date format in GridView

Date May 22, 2007

I set the DataFormatString to {0:d} and also tried {0:MM-dd-yyyy} as several forums and articles suggested; but it still wouldn’t work and kept on displaying the entire string including the time. It turns out, all I had to do is add HtmlEncode=”false”.
<asp:GridView ID=”gridItems” runat=”server” AutoGenerateColumns=”False” DataKeyNames=”ItemId”
DataSourceID=”MyItemsDataSource” Width=”100%”>
<Columns>
<asp:BoundField DataField=”Title” HeaderText=”Title” SortExpression=”Title” />
<asp:BoundField DataField=”Status” HeaderText=”Status” […]

Flip a SQL table around

Date April 10, 2007

I have a sql table that looks like this

Id

Name

Value

1

First name

Bob

1

Last name

Johns

2

First name

John

2

Last name

Smith

3

First name

Bill

3

Last name

Gates

I want to return the data like this:

Id

First name

Last name

1

Bob

Johns

2

John

Smith

3

Bill

Gates

 
I am completely lost and don’t even know where to start or what to search for… Any ideas?

For the time being, I used code to generate the required results, here it […]

Close
E-mail It