Tim Maxey .NET Technology Blog & Resources

February 2009 Entries

Webservice error on the server, but not my local box

My webservice call to, example: service1.asmx/myfunction just wasn't working on the server, but on my local box it worked great, so I had to add entries in the web config... This needs to go between your <system.web> tags in the web.config <webServices>     <protocols>         <add name="HttpGet"/>         <add name="HttpPost"/>     </protocols> </webServices>

Birthday diplayed as age .NET, ASP.NET, VB.NET

I needed to display the age of of a birthday field from a database. I was so tired of coding and came across this function! I got this from a guy named "hans" on a forum, great little function I didn't have to write! Private Function Age(ByVal Birthday As DateTime) As Integer Dim year As Integer = Today.Year - Birthday.Year If Today.Month < Birthday.Month Or (Today.Month = Birthday.Month And Today.Day < Birthday.Day) Then Return year - 1 Else Return year End If End Function

VS 2008 keeps asking to replace AjaxControlToolkit.dll

I had an ANNOYING problem with Visual Studio 2008 and the AjaxControlToolkit.dll. Seemed like if I had an Update Panel on the aspx age, I would get asked if I wanted to replace the AjaxControlToolkit.dll. ANNNOYING, so I did some searching and finally did this: 1. In VS 2008 I had to right click on the toolbar and choose the option "choose items," then I sorted the the .NET Framework Components and unchecked the AjaxControlToolkit version version 3.0.1xxx and keep the 3.0.2xxx. 2. Next I went to the property page of the project and references and removed the AjaxControlToolkit reference, then I...

MaxLength not working in ASP.NET textbox multiLine

Great code I found for maxlength issue with .NET textboxes. .NET textboxes, if TextMode is set to MutilLine, the maxlength property just doesn't work, sux. So after playing around with different soloutions. I found this on, thanks to a guy named "Leo." So a big thanks to him! Add this function in JavaScript on your page, I stuck it my "functions.js" file I include on the page anyway. function checkMaxLen(txt,maxLen) {try{if(txt.value.length > (maxLen-1)) {var cont = txt.value;txt.value = cont.substring(0,(maxLen -1));return false;};}catch(e){}} Then on the textbox use something like  this: <asp:TextBox runat="server" ID="txtComments" CssClass="comment_textbox" Height="75px" TextMode="MultiLine" onkeyup="return checkMaxLen(this,151)"></asp:TextBox> Notice the function passes the textbox...