Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 4 > ASP.NET 4 General Discussion
ASP.NET 4 General Discussion For ASP.NET 4 discussions not relating to a specific Wrox book
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 4 General Discussion section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old February 4th, 2012, 12:19 PM
Authorized User
Join Date: Jan 2011
Posts: 89
Thanks: 1
Thanked 0 Times in 0 Posts
Default Calling Javascript after UpdatePanel has done partial postback

I'm using javascript on my page to limit the characters that can be entered on a multiline text box:

<script type="text/javascript">
         $(function Comments() {
             var limit = 300;

             $('textarea[id$=txtAdditionalComments]').keyup(function () {
                 var len = $(this).val().length;
                 if (len > limit) {
                     this.value = this.value.substring(0, limit);
                 $('#spn').text(limit - len + " characters left");
My counting control that gets refreshed is:

<cc1:TextBoxCounter ID="TextBoxCounter1" runat="server" TextBoxControlId="txtAdditionalComments" DataFormatString="({1}/300 characters)" />
My problem is I have update pannels elsewhere on the page which, when refreshed, stops this from running. I can see lots of solutions online for this but not being a javascript guru I just can't seem to get it to work.

I have tried using this in code behind on the page postback:

ScriptManager.RegisterStartupScript(TextBoxCounter1, TextBoxCounter1.GetType, "Comments()", "Comments()", True)
But no luck. Can anyone tell me how I can get this working??
Old February 8th, 2012, 03:06 AM
Friend of Wrox
Join Date: Nov 2009
Posts: 156
Thanks: 13
Thanked 16 Times in 16 Posts
Default yes, i found it!


Similar Threads
Thread Thread Starter Forum Replies Last Post
Calling Javascript after UpdatePanel has done partial postback AlexW Javascript 2 January 16th, 2013 11:48 AM
Force PostBack in JavaScript sal79 ASP.NET 3.5 Basics 0 May 9th, 2009 02:46 PM
avoid postback using ajax in javascript kalyanykk Visual Studio 2005 1 May 30th, 2008 08:16 AM
UpdatePanel/ModalPopUp Postback Problem jlrolin ASP.NET 2.0 Professional 3 August 13th, 2007 01:23 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.