Never Argue With Stupid People

Silverlight to send email

by admin on Mar.30, 2009, under Programming

For the last couple of days I have been tinkering with a Silverlight control for a webpage that I am contracted to design (if I ever get the specs, that is). It is for a carpet cleaning service, and I thought it would be a neat idea if customers could choose a date or range of dates from a calendar, enter their floor size and a phone number, and have someone call them with an estimate to shampoo their carpets. sched

It is not anything really fancy, but I have not had much opportunity to tinker with Silverlight, so it seemed like a good time to try it out and see what it can do. This form here only took me about 30 minutes to put together, and most of that time was figuring out which attributes did what, and how to add listeners. It works a bit differently than strictly visual programming because you do not drag and drop controls onto the form. you drag the control into the .xaml, and then you tweak the placement until you get it to where you want to go.

The background stuff is still just C#, so that was really no big deal either. The hard part has nothing to do with figuring out the syntax. The hard part is doing form validation, and giving the user good feedback when there is an error. And of course, making sure that there is just enough information so that potential customers can figure out how to use the form. this does not have quite enough information just yet, but at this point, it is just a proof of concept. It is not within the budget that we agreed upon for the page, but I may throw it in just because it is sort of cool. Basically, if the client neglects to fill in one of the boxes, a message is displayed in the area below the button, and the text field with bad information is colored red so that the user knows exactly where they messed up. As soon as the user takes some action, the error prompts disappear, as they should.

It took me a few hours to get it all together, but now that I know what I am doing, a simple form like this should take no longer than an hour or so, including all validation. What makes this form really useful is that once it is filled out, it is emailed to the business, and they can respond with an estimate. Things got a little tricky there. I worked through several tutorials, some of them several times, before I finally got a sample to work. I used the tutorial from Michael Sync to get it going, and it took me a while to realize that there was an error in the sample.

This line is not correct, at least that is the way it went for me. This:

   1: EndpointAddress endpoint = new EndpointAddress(http://localhost:50976/SL2Mail_Web/MailService.asmx);

Should be this:

   1: EndpointAddress endpoint = new EndpointAddress(http://localhost:50976/SL2Mail.Web/MailService.asmx);
 Once I did that, it worked as advertised. Of course, I had to change the port number also.

Post to Twitter Tweet This Post

:, ,

3 Comments for this entry

  • Michael Sync

    Thanks for the correction!! I will take a look at my samples. seems like I need to upgrade some of my samples in my blog.

  • RTWphoenix

    OK, I can not read the solution SORRY. But I am sure this is the problem I have been having all day.

    I can not get the reference to load in SL3 at all.

    Says it can not find the page. When I type in the URL in IE I get a line one error which of course their is non in .net 3.5 webservce creation or at least that is what I get.

    HELP! never used asmx before and I am new to C#

    Thank you for ANY HELP

  • admin

    Did you use the source code from Michael’s page? I could dig out my source code and give it to you (I think I have it). The other things is that this project was done using Silverlight 2. I don’t know if that will make a difference or not.

Leave a Reply

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!