How to do a keyPress inside in a textbox inside a Toolbar

3 posts, 0 answers
  1. Vuyiswa Maseko
    Vuyiswa Maseko avatar
    187 posts
    Member since:
    Jan 2010

    Posted 07 Aug 2010 Link to this post

    Good Day Admin

    i have a Tool bar that is defined like this

    <telerik:RadToolBar ID="RadToolBar1" Runat="server" EnableViewState="False"
                     Height="100%" Skin="Forest" Width="100%">
                     <Items>
                         <telerik:RadToolBarButton Width="100%" runat="server" Text="Button1">
                             <ItemTemplate>
                                
                                 <asp:TextBox ID="txtsearch" runat="server"  CssClass="imgButtonRight"  onkeypress="keyPress()" Font-Size="X-Large" Height="40px"
                                       Width="650px"></asp:TextBox>
                                 
                             </ItemTemplate>
                         </telerik:RadToolBarButton>
                     </Items>
                 </telerik:RadToolBar>

    and i have a property that i will use to access the value of the textbox like this

    public String txtsearchid
    {
        get
        {
     
            RadToolBarItem textItem = RadToolBar1.FindItemByText("Button1");
            TextBox txtseach = (TextBox)textItem.FindControl("txtsearch");
            return txtseach.ClientID;
     
        }
    }

    now the property is working and fine and now in my Client side code i access the value of the textbox ,but i have a keypress event for that textbox that is defined like this on the clientside
    <script type="text/javascript">
        function keyPress() {
            var tb = document.getElementById('Text1');
            var txtsearch = document.getElementById("<%=txtsearchid%>");
            if (txtsearch.nodeValue.length <= 2) {
     
                PageMethods.Getadata(document.getElementById(txt2).value, myFunction);
                alert(msg);
            }
            return false;
        }
        function myFunction(msg) {
            
        }
    </script>

    now my problem is that the keypress event does not get fired when the textbox is in the toolbar

    Thanks

  2. Peter
    Admin
    Peter avatar
    6637 posts

    Posted 10 Aug 2010 Link to this post

    Hi Vuyiswa,

    The following kb article will help you with this requirement:
    http://www.telerik.com/support/kb/aspnet-ajax/toolbar/how-to-trigger-itemclick-event-by-pressing-the-enter-key.aspx


    Best wishes,
    Peter
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Vuyiswa Maseko
    Vuyiswa Maseko avatar
    187 posts
    Member since:
    Jan 2010

    Posted 10 Aug 2010 Link to this post

    My problem is related to this article

    http://www.dotnetfunda.com/articles/article454-using-pagemethods-and-json-in-aspnet-ajax.aspx?com=added


    at the end of the article they have words like

    PageMethods is a simple lightweight way to submit data to the server using ASP.NET AJAX. This doesn't submit whole page data to the server and also as opposed to the ASP.NET AJAX call back this doesn't even fire the Page_Load and other Page events of the code behind page.

    So that is why the RadControls come back as null, how can i mimic the page life cycle.

    thanks
Back to Top