Setting a value of the textbox

3 posts, 0 answers
  1. John
    John avatar
    2 posts
    Member since:
    Nov 2013

    Posted 26 Nov 2013 Link to this post

    Hi,
    I have a following problem. First code:
    <telerik:RadPanelBar runat="server" ID="RadPanelBar2" ExpandMode="SingleExpandedItem" Width="100%">
                <Items>
                    <telerik:RadPanelItem ImageUrl="~/Images/Att.png" Text="MojAtak" runat="server" Expanded="True">
                        <Items>
                            <telerik:RadPanelItem runat="server">
                                <ItemTemplate>
                                    <asp:TextBox ID="ReportBox" class="text" runat="server" Style="height: 99%; width: 98%; font-size: 9px; border-style: none;" TextMode="MultiLine" onkeyup="javascript: czytaj();"></asp:TextBox>
                                    <asp:TextBox ID="txtKto" runat="server" class="text" Height="14px" Style="width: 140px;" Font-Size="Small" BackColor="#CCFFFF" Font-Italic="True"></asp:TextBox>
                                </ItemTemplate>
                            </telerik:RadPanelItem>
                        </Items>
                    </telerik:RadPanelItem>
     
                    <telerik:RadPanelItem ImageUrl="~/Images/Cone.png" Text="Outbox" runat="server">
                        <Items>
                            <telerik:RadPanelItem runat="server">
                                <ItemTemplate>
                                    <asp:TextBox ID="txtKogoS" runat="server" class="text" Height="14px" Style="width: 140px;" Font-Size="Small" ReadOnly="True" BackColor="#CCFFFF" Font-Italic="True"></asp:TextBox>
                                    <asp:TextBox ID="txtDataS" runat="server" class="text" Height="14px" Style="width: 140px;" Font-Size="Small" ReadOnly="True" BackColor="#CCFFFF" Font-Italic="True"></asp:TextBox>
                                </ItemTemplate>
                            </telerik:RadPanelItem>
                        </Items>
                    </telerik:RadPanelItem>
                </Items>
            </telerik:RadPanelBar>
     
            <telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">
                <script type="text/javascript">
                    var ReportBox = '<%=((TextBox)RadPanelBar2.Items[0].Items[0].FindControl("ReportBox")).ClientID%>';
                    var KtoBox = '<%=((TextBox)RadPanelBar2.Items[0].Items[0].FindControl("txtKto")).ClientID%>';
                    function czytaj() {
     
                        alert($get(ReportBox).value);
     
                        var raport = $get(ReportBox).value;
                        if (raport.search("ygrał") > 0 || raport.search("z walki:") > 0 || raport.search("Remis") >= 0) {
                            alert("Kto");
                            //kto
                            var k1 = raport.indexOf("w.", 0);
                            var wynikS = raport.substring(k1 + 3);
                            var k2 = wynikS.indexOf("otrzyma", 0);
                            var kto = wynikS.substring(0, k2 - 1);
                            alert(kto);
                            alert(KtoBox);
     
                        } else {
                            alert("!!!!");
                        }
                    }
                </script>
            </telerik:RadScriptBlock>

    onkeyup - I can access whatever user entered in the ‘ReportBox’ but I can’t update ‘txtKto’.

    If anyone have any suggestion please go ahead. Oh and please keep in mind I'm a rookie.

    Thank you

  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 26 Nov 2013 Link to this post

    Hi John,

    I guess you want to update the TextBox 'txtKto' value based on the value of 'ReportBox' TextBox. Please have a look into the following JavaScript which works as expected for me.

    JavaScript:
    <script type="text/javascript">
        var ReportBox = '<%=((TextBox)RadPanelBar2.Items[0].Items[0].FindControl("ReportBox")).ClientID%>';
        var KtoBox = document.getElementById('<%=((TextBox)RadPanelBar2.Items[0].Items[0].FindControl("txtKto")).ClientID%>');
        function czytaj() {
            alert($get(ReportBox).value);
            var raport = $get(ReportBox).value;
            if (raport.search("test") == 0) {
                KtoBox.value = raport;
            }
            else {
                alert("!!");
            }
        }
    </script>

    Let me know if you have any concern.
    Thanks,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. John
    John avatar
    2 posts
    Member since:
    Nov 2013

    Posted 27 Nov 2013 Link to this post

    Thank you Shinu, worked like a charm.

    Regards

Back to Top