0
votes

I have an asp.net page that contains a gridview within an update panel. On this Gridview there is a number of Textboxes. One of these textboxes causes a postback when it loses focus (textChanged event) and the updatepanel does a postback. I want this textboxes only to do a postback if there are 20 characters in it when it loses focus. I have written a javascript function to do this but I still have a problem. When I do the postback the whole page reloads, not only the update panel. I had something like the below function, can anyone explain how I can get it to only postback the update panel:

<script language='Javascript'>
     function CheckPostback(var textbox)
     {
        if(textbox.value.length() == 20)
        {
            __doPostBack(textbox.Id, '');
        }
     }

</script> 
1

1 Answers

0
votes

Calling __doPostBack with the Id of the UpdatePanel you want to do the partial postback on should be a better bet. See Easily refresh an updatepanel using javascript for more information.

This question ASP.NET: Manually updating an UpdatePanel using jQuery should be useful as well.