Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript
|
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript 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:

Code:
<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");
             });
         });
    </script>
My counting control that gets refreshed is:

Code:
<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:

Code:
ScriptManager.RegisterStartupScript(TextBoxCounter1, TextBoxCounter1.GetType, "Comments()", "Comments()", True)
But no luck. Can anyone tell me how I can get this working??
 
Old February 13th, 2012, 07:35 AM
Friend of Wrox
 
Join Date: Nov 2009
Posts: 156
Thanks: 13
Thanked 16 Times in 16 Posts
Default see samples

Hi my friend

see this link

http://stackoverflow.com/questions/1...panel-postback
__________________
happy every time, happy every where

Reza Baiat
 
Old January 16th, 2013, 11:48 AM
Registered User
 
Join Date: Jan 2013
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by irProject View Post

Works like a charm! Thank you!

I have a listview within an updatepanel that uses a datapager. To get to the top of the page after a partial postback the code below works:

<script type="text/javascript">

function scrollWindow() {
window.scrollTo(0, 0);
}

function pageLoad(sender, args) {
scrollWindow()
}
</script>





Similar Threads
Thread Thread Starter Forum Replies Last Post
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
postback issue with drop downlists with javascript emachines Javascript How-To 1 January 6th, 2005 01:49 PM





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