.NET

There are 41 entries for the tag .NET

Web Application Performance: CSS Data URIs

Was doing my daily research today and learned a couple of new and interesting things. A while back, I wrote a post about rendering options using .NET 3.5 SP1's charting component. I outlined a few of the more conventional/out-of-the-box methods (temporary directory, binary streaming). I also outlined a lesser-known technique in which you stream binary data to the src attribute of your <img> tag. That ends up looking like this... <img src='data:image/png;base64, iVBORw0KGgoAAAA[snip]; />...
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Error Handling in ASP.NET MVC 1 [Part 2 of 2]

In the first post in this series, I provided a little info on the HandleError attribute in MVC 1. In case you don’t want to flip back, the HandleError attribute can decorate a method or a class and will push your users to a generic errors view provided customErrors is “On” or “RemoteOnly”. There’s a little more to it, but that’s all the background we need for this post. The out-of-the-box HandleError attribute works well, until you’re in a scenario where you need to do more than hide your errors....
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Error Handling in ASP.NET MVC 1 [Part 1 of 2]

I’ve been using ASP.NET MVC Release 1 for a bit now, and while it’s definitely not for every application, I happen to like it quite a bit. There has been a lot of activity on MS-centric blogs regarding MVC, but there are still some really mundane tasks that there could be more information on. So, this series of posts isn’t going to be anything crazy; it will, however, illustrate what options you have to do centralized error-handling using MVC 1. We’ll start at the beginning… The System.Web.Mvc.dll...
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Adventures in WF 3.0/3.5

Until redesign of WF 4.0 is completed & released, I’m going to have to put up with this. I’ve been working some WF stuff the past few days. One of the very annoying things about working with the VS designer environment is, well, frankly – the designer. It’s entirely inconsistent. Sometimes, when I need to add a normal property (not a dependency property) – doing things the normal way gets me there. In other words, I add this code to the activity code: public int MyProperty { get; set; } and in...
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Get the index of a given item using LINQ [quick-tip]

UPDATE: Please see first comment to do this the "safe" way... It took a bit for me to get comfortable enough with LINQ-to-objects to write ‘queries’ off the top of my head…but once you’re used to it you realize it’s much more concise, easier to interpret/read, and well..it’s less code. Here are some real quick examples… This first example selects the string array value as well as its position from the someItems array. Note, the user of new{} creates a new generic type that has the properties ItemName...
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Returning values from your LINQ queries [quick tip]

Just a quick tip that I found handy while doing some writing yesterday; chances are if you’ve played with LINQ you probably wrote something like this… var outputString = from s in inputString where s.Length > 1 select s; //Do some stuff with outputString in your method... Code like the above will work perfectly well if what you’re going to work with your implicit variable, outputString, within the body of the same method. But, as it stands, you can’t return outputString, or any implicit variable...
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

If you are thinking about using Windows Work-Flow…you should know…

That MS decided to totally blow it up in .NET 4.0. (weblogs.asp.net link, S/O link). Yes, that’s right, they are totally re-writing WF 4.0 from the ground-up. As the first link states, this could be for any number of reasons including lack of adoption and the perception that WF is just too complex – which I happen to agree with. 3.0/3.5 workflows will still work, but only on the 3.0 runtime. On the one hand, I have to give some credit to MS for basically saying “Hey guys, we effed up and we’re gonna...
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

XmlSerializer & XmlSerializerFactory: I’m sort of positive you aren’t insane.

A few weeks back I was doing some pokin’ around the ol’ web regarding reading XML from somewhere (database, file-system, the trunk of your car) and into an .NET object. In case you weren’t aware…it turns out .NET makes doing this type of work nothing short of trivial. <slightly off-topic background info> That is, if you had XML that you [stole from MSDN] that looked like this… <?xml version="1.0"?> <book> <author>Gambardella, Matthew</author> <title>XML Developer's...
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Adding “Open with reflector” to your right-clicks….

I feel like these days I’m constantly using reflector to dissect assemblies and [can’t believe I’m going to say this but] opening reflector every time is too much work. It just means like it’d be a lot easier if I could right click a DLL and select “Open with reflector” – just like I do with 7-Zip and the Tortoise SVN client. Well…this is how you do that. Adding the “Open with reflector” to your right-click menu Open up windows explorer (Windows Key + E) Go to “Tools” > “Folder Options” &...
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

ASP.NET Charting: Rendering Options

With the release of .NET 3.5 SP1, MS has released a sub-set of the Dundas charting component. They also put together a neat little solution that’ll let you run a number of examples/samples locally so you can get your hands dirty. If you’re looking to do any work with the charting components, or just play around getting these samples should definitely be your first step as the basics will be self-explanatory. The link for that is here. Now that we got the boring introductory stuff out of the way;...
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Learning doesn’t work if you don’t do it right…

So...there isn't really any denying that there is a lot to learn. New releases from MS, new tools from third-party provides, new libraries..whatever it may be. It's pretty unrealistic, at least with my current brain, to be able to learn all of that stuff while still having any kind of a life. Sure, I squeeze in a book on the subway, and my idea of goofing-off at work is going to DotNetKicks.com and checking out what's late and great in .NET today. That all said, I suspect it may be at least as important...
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

What Tools Do You Install On a New Machine?

I recently switched gigs at work and I’ve had re-install, well, all the tools and gadgets that I tend to use. I’ve also seen a bunch of blog posts lately about tools and plug-ins and I love learning what tools are being out there that I can use…SO, I’ve put together a real short and sweet list myself. This is by no means exhaustive! Tool Description Windows Live I switched over some time ago. This is a great tool for blog posts. I also love the code snippet plug-in. CopySourceAsHtml Handy plug-in...
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Pandora Time Out Annoyances? The 1991-style workaround.

I usually don’t stray off the .NET path too much but…I listen to Pandora a lot. I also happen to be a nutcase that listens to music throughout the entire night. Well, if you ever listen to Pandora you know that after an hour it times out…and that can be pretty damn annoying even if all you have to do is go find the tab within FireFox that Pandora is living in and click a button. In any case, I created a really old-skool workaround for this. There are probably 900 ways to do this (another one that...
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Wolfram Alpha “Search Engine” Goes Live @ 5PM [PST]

One of my last big project revolved around keyword based searching using a Google Search Appliance and an open-source API code the Google Search Appliance written in .NET [link]. Ever since then I’ve been intrigued by keyword search technologies, specifically as it relates to their backend logic. That all said, Google searching simply matches for strings with a few exceptions. The guys who developed Mathmetica, though, have developed a processing engine that actually finds answers. By that, I mean...
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Using Forms Authentication with HTML Pages (or, really, any file-type you desire)

So, I recently had to write a small application that would basically prevent anonyomous users from accessing a site...which normally would take all of 5 minutes. The catch, though, was that the site I had to prevent access to was static content...predominantly HTML and Flash movies. Setting up forms authentication at first glance seems to work without issue...until you try to access an HTML file directly. Upon doing so, you'll go to the HTML page without issue for the simple fact that HTML pages...
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

iHttpHandler vs iHttpAsyncHandler

I have been playing with both the iHttpHandler and iHttpAsyncHandler lately, and I came across some interesting information. There are a couple of blog posts out there explaining when to use one over the other (see Mads Kristensen's post here, or Vlad Hrybok's post here) So when does it make sense to use Async? Consensus seems to be that it makes sense to use the iHttpAsyncHandler for long running operations, so while it probably doesn't make sense to use an iHttpAsyncHandler for say, loading images,...
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Useful Links [Random Code Examples and A Memory Management Article]

Came across some links doing my daily research that I believe others would find useful. Mike Woodring has a rather large list of code-examples on everything from remoting and sockets to HTTP Logging modules. It's a really great resource and cruising through this code was definitely a learning experience for me - the more I learn the less I know about before :) Link number two is a refresher on memory management in the .NET framework. I find it's easy to plug-away developing ASP.NET (And maybe even...
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Dynamic Image Loading, Caching, & Performance

I came across an interesting blog posting and comment today doing some research on ASP.NET performance. Essentially, Alik Levin mentions that if you're loading images dynamically (either from a file-system or DB) you will not be taking advantage of browser/client caching out-of-the-box. I'm using a very simple HTTP Handler in one of my applications, the handler, well, handles serving up images in my application - something there are lots of. So it seems like it makes a lot of sense to have the browser...
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

ASP.NET Performance Tips

In the post below I am going to run down a short-list of some of the less-popular performance tips and the reasoning behind them. There are loads of blog postings and articles on asp.net performance enhancements, and I urge you to check those out as well. Onto the good stuff... Session.ReadWrite versus Session.ReadOnly It goes without saying that using the Session object will incur some performance overhead so if possible it should be turned off in the web.config. That said, If you’re using the Session...
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

MS AJAX 4.0 New Feature; Templates

John Katsiotis has a great example up on one of the new ASP.NET AJAX Features, client-side templates. This means that you can refer to properties in your HTML. John has a much better example on his blog, but essentially you can do stuff like this: And your .NET code would basically return an object of type employee to your HTML. The framework will handle populating the input values based on the properties names assigned (e.g., value="{{ PropertyName}}"") public static List GetVal() { List emplist...
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Another Abstract Factory Explanation

Please note, I've moved this post and cleaned it up a bit...you can find it at the following URL: http://geekswithblogs.net/S... Cheers
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Turning validators on from Javascript

Oh the adventures of JavaScript and ASP.NET. Can you turn on validators [RequiredFieldValidators or otherwise] from JavaScript. Yes, and actually it is easier than I thought. ValidtorEnable(ControlId,Tr... Ex: //You could easily make this prettier by not hardcoding the ClientID here ValidatorEnable(document.ge... true); Keep in mind, you need to pass the object not the clientID of the object. Source: http://msdn.microsoft.com/e...
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Convert C# to ActionScript

I'm really just getting started with flash and in the process of doing some research I came across what seems to be very interesting. A free tool that allows a .NET developer to write code that will be translated into ActionScript on-the-fly. It also does C# to JavaScript, and C# to Java. Interesting. The JsC homepage has a lot more information on this...
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

VB.NET & C# Extension Methods

I was recently combing through my code and adding HTMLEncode()s where necessary. By the way, don't leave this to the end - you have no excuse since you're reading this post. The first thought that comes to mind to add this is simple, add a central function, perhaps a shared (vb) or static (c#) function to handle this. It'd likely look something like: Public Function HTMLEncode(ByVal s As String) As String Return If(Not String.IsNullOrEmpty(s), System.Web.HttpUtility.Html... s) End Function...
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

.NET C# Image / Photo Crop Logic

I just posted an article, tutorial, and code on how to crop an image using asp.net and a javascript library. You can check it out here! Tags: ASP.NET Image Crop, ASP.NET Photo Crop, .NET Image Crop
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

ASP.NET Image / Photo Cropper in C#

You can skip to the demo by clicking here You can download the source code by clicking here For my current project I needed to create some logic for users to upload an image...only problem was the image had to be of a fixed size, and therefore aspect ratio. Enter the need for an image cropper. You've seen them before on a number of sites, like linkedIn, facebook, and everywhere else. I began my journey of trying to find one. There are a fair amount of tutorials/code snippets on the web that illustrate...
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Google Search Appliance API in VB.NET

A while back I ported the C# Google Search Appliance API to VB.NET. You can find it here. The original API was ported over from JAVA by MC+A. Enjoy...
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Login Control, Default Button, ugh.

Yes, you can definitely find this information elsewhere but...what happens when you want to use a login control on a page and also use the default button property so when a user hits enter it submits the login control's button. Nothing, because you have no idea what the hell the ID of the submit button is. Here is the workaround: <asp:LinkButton ID="lnkbtn1" runat="server" /> <asp:Panel ID="pnlLogin" runat="server" style="display:none" CssClass="modalPopup" DefaultButton="Login1$Login...
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Default Button Workaround for imagebuttons & linkbuttons, Part II

Okay...so, the post yesterday was clearly not as researched as it should have been. It's true...the Click() event does NOT work in FF...so, the solution I had to utilize the click event had a rather short lifespan. I tried to dynamically add the __onPostBack javascript event onKeyPress as well as onkeydown - to no avail. I'm not sure why it wouldn't work...but, it just wouldn't. (I'm using an image button, .NET 3.5, a lot of JS & AJAX on the page - not sure what, if any of that muddies the waters)...
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Default Button Workaround for imagebuttons & linkbuttons

UPDATE: If you're looking for the solution that will work in FireFox & IE...Go here Okay, I admit, this is yet another post so I know where to go in 3 months when I totally forget this day. Long story short: I was trying to use the DefaultButton property on a panel in order to get a button clicked by default when a user hits enter on my search form. I was using an ImageButton, and surprise! That won't freakin' work! Seriously...try it. I came across a post on here ( http://bytes.com/forum/thre...
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Send e-mail with attachment from database image column (sql server 2k5)

Soooo...I needed to get files out of my SQL Server table (which has the files in an image column) and attach them to an email to send out. I honestly thought this would be a no-brainer but turned out it was pretty finicky. Anyway...the code to so is below just in case anyone is wondering. Partial Class _Default Inherits System.Web.UI.Page Function SendEmail() 'Get your data (filename, content type, image column) from the db Dim dt As DataTable = GetYourStuff() If dt.Rows.Count <= 0 Then Return...
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Alternatives to FindControl()?

Alright, as much as I try to avoid using FindControl() sometimes I need to get a control by its ID. I came across what seems like a good idea here : http://www.thescripts.com/f... It's in C#, but here is the VB.NET adaptation... 549 Private Sub BuildControlHashTable() 550 Dim cName As String = String.Empty 551 For i As Int16 = 0 To Me.Controls.Count - 1 552 cName = Me.Controls(i).ID 553 If Not (cName Is Nothing) Then 554 cntrlHashTbl.Add(cName, Me.Controls(i)) 555 End If 556 Next...
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Export to vCard from .NET (VB.NET)

Hi all - So was poking around a few weeks ago and couldn't find any code that'll allow me to export data to vcard...The class would require a little modification to utilize, but should get you 90% of the way there Partial Class vCardExport Inherits System.Web.UI.Page Private Const nameFirst As String = "FirstName" Private Const nameLast As String = "LastName" Private Const nameMiddle As String = "MiddleName" Private Const nameTitle As String = "Mr" Private Const email As String = "firstname.lastname@domain....
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

SqlSiteMapProvider in VB.NET

UPDATE 6.18.2008: You can download the file from here Alright, so I wanted to build a dynamically/DB driven role-based menu system utilizing framework 2. I started with this article… http://msdn.microsoft.com/m... And then converted to VB.NET…Not to come across some items that I needed to change… I came across the following errors: “'System.Web.Caching.CacheI... is a delegate type and requires a single 'addressof' expression as the only argument to the...
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Copy source as HTML

Found this neat tool from Colin Coller. Basically, let's you copy code as HTML (right-click option) in VS.NET 2k3/5. Handy for posting code to the web
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Localhost blocked? Changing the default debug address in VS.NET 2k5

Greetings. So I ran into a bit of an annoying challenge today. For months now, I've had IIS installed locally. I work on my local project/sln's, and save them - then update to our source control server Everyone was happy for awhile there. Anyway, I guess security made some modifications to our AD Security Policy, so if I try to reach http://localhost/Projects/W... I'm pretty much out of luck. In any case, you can subvert this in VS.NET by modifying your .CSPROJ file. <WebProjectProperties>...
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Ajax Animated GIFs

Hey all,Came across two great resources for using/generating animated GIFs for your AJAX enabled projects...The first one is a site that dynamically generated animated GIFs for your use...The second is control that lets you display a "wait message". It's best to check out the demo on this. A neat feature of this is the ability to display the "wait message" during a page_load. This control reminds me of this...
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Some handy Windows Tips

Querying and Dropping Windows Terminal Service Sessions RemotelyI often run into scenarios where I can't access a server via Terminal Services because there are no available sessions. This usually means there are too many people signed on, or one or more sessions have hung in a disconnected state. So how do you check? You connect (via TS) to another server and utilize the following utilities.This will list users that are on the server whose IP you provide, as well as the state of their connection>QWINSTA...
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Where did Designer.CS go?

Alright so…on my latest project I decided to use .NET 2.0. Things were going great, until I ran into the following scenario (if you googled to here, skip my rant and just go to the solution…it’s down there somewhere) …I had a user created control. This control consisted of 4 dependant drop down lists and a submit button, all of which are AJAX based utilizing Jason Diamond’s library generating of a DB2 backend. Neat-0. I wanted to trigger an event on my main page (default.aspx) when the submit button...
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Thinking like a genius?

http://www.studygs.net/geni
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Anthem Ajax Library

So I drudged through a bunch of different Ajax libraries freely available on the web. I'm a bit reluctant to build any apps w/atlas naturally since it's not out yet. (On a side note, I couldn't really find any useful Atlas articles on the web - anyone got any?) Initially, I played with Michael Schwarz's (I needed to build some dependant drop down lists) However, this library was a bit lacking in one important area. ViewState. I couldn't access the ElementID.SelectedValue property as you normally...
  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Twitter