Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
<asp:TextBox ID="TextBox8" runat="server" Width="268px"  
                        onChange="$find('AutoCompleteExtender3').set_contextKey(this.value);" 
                        ontextchanged="TextBox8_TextChanged" AutoPostBack="true"></asp:TextBox> 
 
This is my code
Please notice the
AutoPostBack="true"
and
onChange="$find('AutoCompleteExtender3').set_contextKey(this.value);"
 
My autpostback is not working because of onchange event.
 
If I remove the onchange event then its working perfectly.
Please suggest any alternative way, Because I need both of them.
Please help.
Posted 5-Jan-13 6:40am
Edited 5-Jan-13 6:41am
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

you might try
 
<asp:TextBox ID="TextBox8" runat="server" Width="268px"
        onChange="$find('AutoCompleteExtender3').set_contextKey(this.value); __doPostBack('TextBox8','');"
        ontextchanged="TextBox8_TextChanged" AutoPostBack="true"></asp:TextBox>
 
This should, in theory, force the postback after the set_contextKey is called. I haven't tested this though, so let me know if it doesn't work.
  Permalink  
Comments
Sourav Sarkar-SS2 at 5-Jan-13 12:49pm
   
Thanks for reply
but the code is not working for me.
No Error, but the output is as previous, autopostback is not working
Please help
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Hi,
 
You can try one other thing, instead of putting everything like this below -
<asp:TextBox ID="TextBox8" runat="server" Width="268px"
        onChange="$find('AutoCompleteExtender3').set_contextKey(this.value); __doPostBack('TextBox8','');"
        ontextchanged="TextBox8_TextChanged" AutoPostBack="true"></asp:TextBox>
 
I suggest you try the below alternative -
first add a script tag in your page & put the javascript content in a function & then call this function (as below). Also add a return true in the function -
<script>
function AutoCompleteExtend()
{
  $find('AutoCompleteExtender3').set_contextKey(this.value);
  return true;
}
</script>
 
<asp:TextBox ID="TextBox8" runat="server" Width="268px"  
                        onChange="javascript:return AutoCompleteExtend();" 
                        ontextchanged="TextBox8_TextChanged" AutoPostBack="true"> 
Again please note this hasn't been tested. Kindly request you to test this & let me know ...
 
Regards
  Permalink  
v2
Comments
Sourav Sarkar-SS2 at 6-Jan-13 13:30pm
   
No,
Not working!
Same problem exist
No Autopostback.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

Try this:
<asp:textbox id="TextBox8" runat="server" width="268px" onchange="$find('AutoCompleteExtender3').set_contextKey(this.value); return true;" ontextchanged="TextBox8_TextChanged" autopostback="true" xmlns:asp="#unknown"></asp:textbox> 
 

--Amit
  Permalink  
Comments
Sourav Sarkar-SS2 at 6-Jan-13 13:27pm
   
Thanks for the answer
But Not working
Sorry
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

Just the idea: you can choose to remove auto postback and write explicit Ajax post in your handler of your OnChange event handler.
 
I would perfectly understand that you want both the postback and this event. Probably, you first do some local processing on the client side using this event and newly updated value of the text box (entered text) with JavaScript, and then you need to notify the server by sending the HTTP request. When HTTP server processes the request, new updated part of page is generated out of HTTP response and the cycles starts over.
 
If this is your scenario, it can be quite reasonable; this is what Ajax is actually used for. At the same time, I would advise you to review it, as the event OnChange can be too frequent. You need to consider performance cost of the exchange with the server on each event. Overuse of Ajax is actually a curse of many present-days site: developers make them actually working, but they don't care about how much it costs due to wildly redundant traffic use.
 
Nevertheless, if you still decide to keep to having both client-side event handling and postback on each event, you can remove auto postback and send Ajax HTTP request in the JavaScript code of you event handler. One of the possible ways to do it is using jQuery Ajax methods. Please see:
http://api.jquery.com/category/ajax/[^].
 
Good luck,
—SA
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Mobile
Web02 | 2.8.141220.1 | Last Updated 17 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100