This is a migrated thread and some comments may be shown as answers.

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

2 Answers 27 Views
ToolBar
This is a migrated thread and some comments may be shown as answers.
Vuyiswa
Top achievements
Rank 2
Vuyiswa asked on 07 Aug 2010, 08:58 AM
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 Answers, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 10 Aug 2010, 01:49 PM
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
0
Vuyiswa
Top achievements
Rank 2
answered on 10 Aug 2010, 03:21 PM
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
Tags
ToolBar
Asked by
Vuyiswa
Top achievements
Rank 2
Answers by
Peter
Telerik team
Vuyiswa
Top achievements
Rank 2
Share this question
or