Tim Maxey .NET Technology Blog & Resources

Friday, February 06, 2009

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 went to my aspx page and re-added the ToolKitScriptManager back to the page.

That did it!


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 (this) and the maxlength you want, in this case 150, notice I have 151, the function will limit the maxlength minus one... So if you want to limit the textbox with mutiline set to 100, you enter 101, make sense?