Archive / JavaScript

RSS feed for this section

ASP.NET MultiLine TextBox MaxLength Validation

There have been many articles and forums addressing the fact that the MaxLength property of the ASP.NET TextBox does not work when you set TextMode to MultiLine. The majority of these solutions use the KeyPress and OnBlur events. This brings with it lots of JavaScript and a host of browser issues. I was impressed by […]

jQuery Get Next Textbox in a GridViewRow

In a GridView I have a column of checkboxes and a column of textboxes. I wanted to modify the value of the textbox when the checkbox is checked. jQuery is the perfect fit for this. Here is the code I used: $(function () {     var $inp = $('input:checkbox');     $inp.bind('click', function () {         […]

JavaScript Objects

See article: Create Advanced Web Applications With Object-Oriented Techniques

Setting WatermarkText in JavaScript

To set the Watermark Text of a TextBoxWatermarkExtender in the AJAX Control Toolkit, use the following code: var behavior = $find(‘<%= TextBoxWatermarkExtender1.ClientID %>’); behavior.clearText();behavior.set_Text(‘Hello World!’); behavior.initialize(); It took me a while to find that I needed to call the Initialize() function before the Watermark Text would get updated. Update September 25, 2012 It appears that […]

ASP.Net AJAX Animations

Some of the best resources for the animation framework that comes with the ASP.Net AJAX Control Toolkit can be found at the live toolkit site at this Sample Site. I often look at the Animation Reference section of this site. While adding animations to ASP.Net pages, it is sometimes necessary to call animations directly from Javascript […]

JavaScript Code To Toggle Check Boxes

Here is some JavaScript code to toggle check boxes (same action as radio buttons). In the page load event register the JavaScript:    chkTwoYear.Attributes.Add(“onclick”, “javascript: CheckTwoProgram(” + chkTwoYear.ClientID + “);”);    chkFourYear.Attributes.Add(“onclick”, “javascript: CheckFourProgram(” + chkFourYear.ClientID + “);”); In the HTML of the page add the JavaScript: <SCRIPT Language=”JavaScript”><!– function CheckTwoProgram(id) {    if(id.checked)       document.forms[0].chkFourYear.checked=false;    } function CheckFourProgram(id) {    if(id.checked)       document.forms[0].chkTwoYear.checked=false;    } //–> </SCRIPT>

How to run client side javascript on a server control

Here is some code to run a javascript function on the client side when a value changes in a drop down box. In this case I have a list of dates populating a drop down box. When the date changes the value of a DIV section changes to a corresponding end date. In the appSetting […]