- Posted by Justin on September 29, 2008
I just spent a bit of time trying to figure out why my GridView was randomly doing a double postback when deleting rows. When I hooked up the debugger and put a break point on in the Page_Load, I would see that it was being called twice. It turns out that there is a bug with the GridView that causes this behavior. If you use either a LinkButton or regular Button, the GridView works as expected. There is also a workaround @ http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=105123
- Posted by Justin on July 24, 2008
This is a book that should be in your library if you are going to be doing development with ASP.NET AJAX.
Typically when you start learning ASP.NET Ajax all of the material centers around UpdatePanels and leaves out anything to do with the client-side scripts. This book will make you realize how much functionality you are missing by only using UpdatePanels.
Also, this book not only covers learning the ASP.NET AJAX client scripts but how to do object oriented javascript development.
- Posted by justin on June 27, 2008
Several times I have had the need to take a collection and convert it to a delimited string for displaying in the UI. I have been using the code below that I found on a blog that I have since lost the link to. However, while at the SEVDNUG meeting tonight Rob showed me an easier way to get the same output using LINQ.
Original Code:
public class CollectionUtilities
{
public string Join<T>(string delimiter, IEnumerable<T> items, Converter<T, string> converter)
{
StringBuilder builder = new StringBuilder();
foreach (T item in items)
{
string converted = converter(item);
if (string.IsNullOrEmpty(converted) == false)
{
builder.Append(converted);
builder.Append(delimiter);
}
}
if (builder.Length > 0)
{
builder.Length = builder.Length - delimiter.Length;
}
return builder.ToString();
}
}
New Code:
public class CollectionUtilities
{
public string Join<T>(string delimiter, IEnumerable<T> items, Converter<T, string> converter)
{
return string.Join(delimiter, (items.Where(i => string.IsNullOrEmpty(converter(i)) == false).Select(i => converter(i))).ToArray());
}
}
NUnit Test:
[Test]
public void JoinTest()
{
string[] joins = new string[]{"1", "2", "3", "4"};
string joinTest = new.Join(",", joins, item => item);
Assert.AreEqual("1,2,3,4", joinTest);
joins = new string[] { "1", "", "3", "4" };
joinTest = new CollectionUtilities().Join(",", joins, item => item);
Assert.AreEqual("1,3,4", joinTest);
joins = new string[] { "1"};
joinTest = new CollectionUtilities().Join(",", joins, item => item);
Assert.AreEqual("1", joinTest);
}
- Posted by justin on September 27, 2007
I have had a problem for ages with when a build fails in CCNET is runs the file merge tasks that are part of my publishers to include the nunit test results. I finally got around to implementing something to delete those results xml files before the build runs. Originally I was just going to add it to nant but I found in the CCNET docs that there is now a prebuild section. One of the tasks included with the CCNET is an exec but it is not very clear on how to use CMD instead of creating a separate batch file. Luckily someone else figured this out at posted it to the mailing list @ http://groups.google.com.ag/group/ccnet-user/browse_thread/thread/d3f19074845bacf7/f58fa4bf7e221b3d?lnk=gst&q=prebuild+&rnum=9#f58fa4bf7e221b3d
Just in case the link goes away, below is how to do it.
<prebuild>
<exec>
<baseDirectory>C:\Temp</baseDirectory>
<executable>CMD</executable>
<buildArgs>/C RD "%ccnetworkingdirectory%" /S /Q</buildArgs>
</exec>
</prebuild>
- Posted by justin on September 26, 2007
Pretty good article on different concepts for implementing load balancing in asp.net.
http://www.c-sharpcorner.com/UploadFile/gopenath/Page107182007032219AM/Page1.aspx
- Posted by justin on February 16, 2007
When I originally started using visual studio 2005 the web application project was just publicly released so I choose not to use it. The web site project seemed to work fairly well for what I needed. However, the more I used it the more I could not deal with the compile times. It would literally take 5+ minutes to compile the web site. I also started having issues with dependencies and a nasty invalid memory location error for the web.config that we could not get rid of on all of the developers machines.
So this afternoon, I finally made the jump to the web application project. I was expecting it to be a difficult process but overall it went ok. I had three problems: 1.) the files that used to be in the app_code were now in the old_app_code and they were not listed as compile items. 2.) I had to run the convert to web application project multiple times to get all of the files to convert 3.) my web services code behind files were listed in the app_code before, I had to move them back to the correct directory so that they could be associated to the asmx file.
To do the migration I followed the tutorial at http://webproject.scottgu.com/CSharp/Migration2/Migration2.aspx