Link to home
Start Free TrialLog in
Avatar of kishan66
kishan66Flag for United States of America

asked on

Call ServerSide OnTextChanged from JavaScript on keypress of Radtextbox

HI,

I have a Telerik RadTextBox and I want to call server side radTxtSearch_OnTextChanged method from javascript onKeyPress event of this TextBox.

ONkeyPress event is called ... but serverside code is not being called.

Also , once the server side code is executed, the value entered in the textbox should be retained.

NOte: I can use ASP.TextBox instead of Telerik.

Please advice....

 
<telerik:RadTextBox ID="radTxtSearch" runat="server" Width="100%" OnTextChanged="radTxtSearch_OnTextChanged" AutoPostBack="true">
                                            <ClientEvents OnKeyPress="OnKeyPress" />
 </telerik:RadTextBox> 

-----
<telerik:RadScriptBlock ID="RadScriptBlock_PN" runat="server">
    <script language="javascript" type="text/javascript">
         function OnKeyPress(sender, eventArgs) {
                      var searchText = document.getElementById('<%= radTxtSearch.ClientID %>');
                        __doPostBack('searchText', 'TextChanged');    // this is not working
         }
    </script>
</telerik:RadScriptBlock>
---------- 
-----Aspx.cs----
protected void radTxtSearch_OnTextChanged(object sender, EventArgs args) 
        {}

Open in new window


Thanks
Avatar of kishan66
kishan66
Flag of United States of America image

ASKER

anybody?
Avatar of Mlanda T
Your proposed model is not ideal on a website. In order to execute the TextChanged event, you will have to do a full page postback on each keypress. This will make typing into that RadTextbox a really horrible experience for your users.

What exactly are you trying to achieve? Perhaps we can also give some insight into what might be an alternative approach to accomplish what you want without hurting the user experience.
basically, i have a RadTextbox & a Radlistbox with values.
i want to filter the Radlistbox values based on the text entered in the RadTextbox (something like google autotext).

List should be filetred on every keychar entered.

Thanks for trying to help.
ASKER CERTIFIED SOLUTION
Avatar of Mlanda T
Mlanda T
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial