Codeine .Net RSS 2.0
# Sunday, January 7, 2007

    Well, the guy who has taught me everything I know about .NET, Bigyan, has taken off for a month to go back to Nepal to get married, leaving me with some very big shoes to fill while he is gone.  While he is gone I have adopted a new philosophy that I am trying to follow, WWBD, What Would Bigyan Do?
    While working on some bug fixes for a web application that we currently have in pilot testing for a client, I found myself working hard trying to prevent a post back, which I knew is exactly what Bigyan would do to increase the quality of the user experience.  I needed to create a custom validator in ASP.NET and could have easily just made it a server side validation, but this would require a post back before telling the user that there was an input error.  The way to eliminate this post back is to create a client side validation function using  JavaScript.
    This first thing that is necessary is to add a CustomValidator control to your page and to associate it to a control on the page by setting the ControlToValidate property. 
    Next, I would typically set the text of the CustomValidator control to an *.   This is the text that shows up on the page where the custom validator exists.  I normally position the CustomValidator either next to the control I am validating or next to the label for the control I am validating.  The * then indicates to the user that there is an error with that field. 
    Following setting the text I set the ErrorMessage property of the CustomValidator to the error message I want to display.  This message will then appear in the validation summary control if you have placed one on the page.
    Now its time to do a little coding.  First thing you will want to do is code up the server side validation for the validator.  This part of the validation is important in case the user's browser doesn't support JavaScript or the user attempts to bypass the script on the client side.
    In my particular case I was validating a rich textbox control that was required.  In my particular case the control would be blank either if it was actually blank or if it had "<p>&nbsp</p>", hence I could not just use the RequiredFieldValidator.  To code the server side check you use the ServerValidate event of the CustomValidator control and check the value property of the args objects that is passed in by the system.  Perform your logic and if the value passes set args.IsValid = True, otherwise set it to False. 

Protected Sub CustomValidator1_ServerValidate(ByVal source As System.Object, ByVal args As System.Web.UI.WebControls.ServerValidateEventArgs) Handles CustomValidator1.ServerValidate

            If String.IsNullOrEmpty(args.Value) Or args.Value = "<p>&nbsp;</p>" Then
                args.IsValid = False
                args.IsValid = True
            End If

        End Sub


   This function will then execute when a button that has its CausesValidation property set equal to true is clicked.  Then, at any point in time if you want to check if all the validators on a page are valid you check if Page.IsValid is equal to true.

            That’s it for handling the server side validation, but the next step is to handle the client side validation so that the client is not forced to look at a post back before knowing that they have an invalid input field.

            To handle the client side validation you just need to write a simple JavaScript function that takes two parameters, sender and args.  You can then evaluate args.Value against your logic, and set args.IsValid equal to either true or false.


  function TxtQuestionValidate(sender, args)


     if (args.Value == '' || args.Value == '<p>&nbsp;</p>')


            args.IsValid = false;




            args.IsValid = true;






You have a couple options for placing the javascript function.  The simple way would be just to put it right into the .ascx page.  Whereas this is easy, I try to steer away from this as you would then need to place this function in every page where you need it.  I prefer to write a service layer function that returns it to me as a string and then insert it into the page on the page load event as follows:


Page.ClientScript.RegisterClientScriptBlock(Me.GetType(), "TxtQuestionValidate", Services.GeneralService.GetTxtBoxValidateJavascript(), True)


            Finally, you need to tell Studio to use this function as the client side script so on your custom validation control simple set the ClientValidationFunction to the name of your JavaScript function.  You now have a custom validation with a client side script to prevent a post back, which I am pretty sure is what Bigyan would do.  I hope he’s having a good time in Nepal, but I’ll be happy to have him back in 25 days.  Its boring going to Starbucks by myself!



Sunday, January 7, 2007 7:00:00 AM (Central Standard Time, UTC-06:00)  #    Comments [0] - Trackback - Save to - Digg This! - Follow me on Twitter
Original Posts
# Friday, January 5, 2007

     Well, I've been slacking on getting the next blog post out on the steps I used to build my DVR.  I will hopefully get time to post the next steps soon, but for now I just wanted to post an updated on my hardware setup.  Like I had posted earlier, I been wanting to increase the memory in the computer.  It started out with 512MB which was working fine, but I am sure the system would suffer if I was recording two shows and watching a recording.  I went ahead and added 1GB more of memory, giving me a total of 1.5GB.  I didn't do any specific benchmark testing, but the picture did seem to look a little better.  I really wanted this memory boost for when I add an HD tuner card to the system, which I hope to do in the next couple months.
     The other thing I added was another fan to the system.  I have been experience system lockups about every 2 to 3 weeks and I think it is because the system is overheating.  The box lives on the bottom shelf of a wood entertainment stand so I have a feeling the heat is building up in the enclosed space.  I hope this extra fan with resolve the issue.
     That's about it for now.  For those of you keeping track of the total investment so far that I have put into the system, the fan was $2.99 and the memory was $89.99.  I got both from and including shipping they came to $99.27.  Hopefully I'll have time to get the next few DVR steps up soon.

Friday, January 5, 2007 7:00:00 AM (Central Standard Time, UTC-06:00)  #    Comments [0] - Trackback - Save to - Digg This! - Follow me on Twitter
Original Posts
# Sunday, November 26, 2006

    Well, for sometime now I have been working on building a DVR from a computer.  After several months I am finally at a point where I consider the project done, and I have decided to post a how-to so that others can build one of their own and hopefully bypass a few of the pitfalls that I hit and benefit from my time Googling.
    I chose to build my DVR using MythTV, a Linux DVR platform, and specifically I used the KnoppMyth version.  Why didn't I use Windows Media Center?  Well, I'm a big fan of the open source movement, and KnoppMyth offers a wide variety of features for free.  Several co-workers have pointed out that I could have saved a lot of time and money by either buying a Tivo for about $100 at Best Buy, or paying an extra few bucks a month and get a DVR through my cable company.  I chose to build my own because it has a lot more functionality than you basic DVR.  I also have the ability to rip my music collection to it as well as my DVD collection.  It has a screen that shows me the weather for my area, as well as a feed reader.  Since its open source there are many add ins for everything you could desire.  I also have the ability to link several of then together (which I plan to do) so that I can stream shows to different rooms in the house.  Not to mention the fact that since it is a standard computer I can continue to upgrade it as much as I want.  Also, I have no monthly fees so I could rationalize a little more up front cost.
  This is the first of a several part post to walk through the setup and configuration settings I used for my setup of KnoppMyth.  Hopefully it will help others through the problems I encountered along the way.
    In this first post I would like to list the spec's for my setup and a few of the requirements that you should take care of before getting started.
    The computer I am using is a Compaq Presario SR1910NX I picked up at CompUSA for $200.  The general specs are as follows:

  • Motherboard: Asus A8N-LA
  • Processor: Sempron (P) 3200+ 1.8 GHz
  • Chipset: GeForce 6150 LE
  • Memory: 512 MB
  • Storage: 120 GB SATA 3G
  • Media: CD Writer DVD Combo
  • Sound: Integrated
  • Network: Integrated 10/100 NIC

There are no particular reason I picked this computer to use. I actually bought it to use for a web server, but reallocated it towards this project instead.  The one thing you should steer clear from is a VIA chipset.  Most of them just don’t seem to work with the software.
The rest of the default specs are fairly standard, but feel free to view the link above to get all of the other specs.   To turn the computer into a DVR I added several other hardware pieces. The first necessary component is a TV tuner card.  I wanted to be able to record two shows at once, or watch one show and record one so I got the PVR 500 by Hauppauge.  This is a dual analog tuner built onto one PCI card which I purchased from NewEgg for $144.98 including shipping. I chose it for the fact that it would only use one expansion slot in my computer.  One problem I ran into with this card is that Hauppauge had recently switched it to use a Samsung chip which apparently poorly affected the video quality from previous versions.  Thankfully I found a patch that corrected the video issue and I am happy with the quality now.  From my research the single turner version, the PVR150 does not cause the same video issues as the PVR500, but I have not used it.


The next necessary addition was a video card.  The computer did have integrated video, but with only VGA out.  I added a card with both svideo out and DVI out.  I currently have a 42 inch widescreen HD TV that the DVR is hooked up to.  I am only connected to it by svideo at the moment, but I would eventually like to switch it over to the DVI.  The card I got is an NVIDIA Geforce 6200LE 256MB (128MB on board) made by BioStar with a PCI Express interface.  I also got this from NewEgg for $41.98 including shipping.  I was very happy with the card as it worked right out of the box without much of any configuration.  One thing I learned purchasing this product is to look at how many MBs are on board.  As you can see this card says it has 256MB.  If you look closer you will find that it only has 128MB on board and it uses system memory for the rest.

The last piece of hardware I added was a remote.  The remote I bought was the Streamzap PC remote from Streamzap Inc.  This remote connects to the computer via USB and worked out of the box. I bought this remote from Provantage for $29.58 including shipping.

This is currently my entire hardware setup.  There are two spots where I would have made modifications and plan to in the future.  The first is more memory.  In my opinion it would be best to have at least 1GB and I plan to go ahead and just add another 1GB once I find a good deal on it.  This will give me a total of 1.5GB of memory.  When I am recording I can see that memory usage is maxed so I think the system would benefit from more memory.  The second thing I would modify is the storage space.  I currently have 120GB.  This is fine, but I have to make a point of getting shows deleted promptly.  I think it would be best to have 250GB.  With this amount I don't think anyone would have very may problems unless they are ripping a lot of music and movies to their system.  I plan to add more storage space sometime, but it isn't a major priority.
The last thing I would like to eventually add is a HD over the air tuner so that I can record my local channels in HD.  These run about $100 and I will post more specifics about this once I pick one up and get it installed.

The last thing I want to go over are a few pre-installation things that need to be done.  The first is to download and burn the iso for the KnoppMyth install.  The current version which I am using is R5D1.  Download it and burn a bootable installation cd. 

The second thing you will want to do is sign up for an account on the forums for KnoppMyth.  I received a lot of help from the users there that was very valuable.  The other place with very helpful information and how-tos is the Wiki.  These two places provide extensive information for setting up a KnoppMyth system.

The last thing you will need do to is sign up and configure you account on Zap2it Labs.  This is the account your system will use to get its TV listings.  I don't specifically remember what the sign up process is as it has been a long time since I filled it out, but I don't recall any issues.  There is a how-to on the Wiki about installing that references using the code 'TGYM-ZKOC-BUTV' so you may need it, but I don't recall.

That's about it for now.  Next time I'll walk through the basics of handling the install and point out the areas where I ran into some troubles.

Sunday, November 26, 2006 7:00:00 AM (Central Standard Time, UTC-06:00)  #    Comments [0] - Trackback - Save to - Digg This! - Follow me on Twitter
Original Posts

<January 2007>
About the author/Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2020
David A. Osborn
Sign In
Total Posts: 70
This Year: 0
This Month: 0
This Week: 0
Comments: 33
Pick a theme:
All Content © 2020, David A. Osborn
DasBlog theme 'Business' created by Christoph De Baene (delarou)