How to find the RadTextBox ,In side Rad Grid Using Javascript.

7 posts, 2 answers
  1. Sairam
    Sairam avatar
    56 posts
    Member since:
    May 2013

    Posted 24 May 2013 Link to this post

    I Have rad grid Inside ,I have 5 column, In that one column consist , Rad text Box ,in "insert Item" template ,And also I have Rad window Inside  ,The Rad window manager ,In the rad window  content template consist of the ,rad text Box 2, user give value and click on, OK Button ,I want transfer the value to "Rad Text  Box" Inside the rad grid . I want to These operation "In rad grid and edit mode".
    In Need these operation using "javascript" .
    How to access the rad-grid,column and controls in it,using java script  
    ex:-
    1.rad grid1-->master table---> 5 columns-->1 column--> item template
                                                                                          insert item template
                                                                                                         <rad text box>

    2.rad window manager-->windows-->rad window-->content template-->Rad Text Box---> access

    Radtextbox1.text=RadTextBox2.text;

    How to access the both ,in using java script
    like
    <"%=radgrid1.client-id%=">

    Help me telerik team.
  2. Answer
    Marin Bratanov
    Admin
    Marin Bratanov avatar
    3600 posts

    Posted 28 May 2013 Link to this post

    Hi Sairam,

    You can use the ItemCreated event of the RadGrid to store the ClientID of the controls that are created in the EditItemTemplate in a hidden field, then use JavaScript to get that information and access the controls. This is needed because these controls are not created with the initial page load and the standard code block cannot be used to access them. Thus, the event when they are created is used to store information about them. I am attaching here a simple page that shows this. You will see that I am not using a RadWindowManager as I advise that you keep windows that use their ContentTemplate out of a RadWindowManager. Another approach is to use jQuery and build a selector that will obtain the IDs you need to access the controls, you could use a custom CSS class on the element that wraps your controls to make the cascade easier.


    Regards,
    Marin Bratanov
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Sairam
    Sairam avatar
    56 posts
    Member since:
    May 2013

    Posted 30 May 2013 Link to this post

    Thanks
    Marin Bratanov ,
    But I want  access  "Rad Grid" and "rad window"  client  side  using "Ajax call " ,I required the how to access ...."through " java-script or jquery ....acess the rad-grid..in side controls....Rad Text-box and Rad Button's ....   
    and also I need how to access "rad window " inside content template  ..Rad Text-box.

    can yours provide some snippet.
  5. Marin Bratanov
    Admin
    Marin Bratanov avatar
    3600 posts

    Posted 30 May 2013 Link to this post

    Hello Sairam,

    My previous sample shows how to access the controls on the server, both directly in the ItemTemplate, and in the ContentTemplate of a RadWindow that is inside the said ItemTemplate. You can use the approach described here to get the needed references. For dynamically created controls like in this case you can use the hidden field values instead of server code blocks directly.

    I have shown how to access these controls both on the server and on the client. Accessing them on the client during an AJAX request does not make sense as a scenario because:
    - this is still either client-side, or server-side access to the controls
    - if they are updated with the partial postback you can have issues with the client-side references you are using (i.e. they will be lost)

    If "access the controls using ''Ajax Call'" means something else - please explain what you have in mind.

    Regards,
    Marin Bratanov
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  6. Sairam
    Sairam avatar
    56 posts
    Member since:
    May 2013

    Posted 30 May 2013 Link to this post

    Hello Marin Bartanov,

    .aspx

    <telerik:RadWindow ID="RadWindow2" runat="server" Behaviors="Default" InitialBehaviors="None"
                    Width="340px" Height="170px" Title="Reset Confirm">
                    <ContentTemplate>
                        <table>
                            <tr align="center">
                                <tr>
                                    <td colspan="3">
                                    </td>
                                </tr>
                                <td rowspan="3" style="width: 40px;">
                                    <asp:Image ID="imgChkNopanel" runat="server" ImageUrl="~/images/informationbank.png"
                                        CssClass="ImgHdAlertCss1" />
                                </td>
                                <td colspan="3">
                                    <asp:Label ID="lblChkNoPanel" runat="server" Text="Enter another check number." CssClass="Content2Css"></asp:Label>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <asp:Label ID="Label7" runat="server" Text="Check No."></asp:Label>
                                </td>
                                <td>
                                    <telerik:RadNumericTextBox ID="RtbChkNumberinInsertMode" runat="server" EmptyMessage="Enter Reset Check NO "
                                        Type="Number" MinValue="1">
                                        <NumberFormat GroupSeparator="" DecimalDigits="0" />
                                    </telerik:RadNumericTextBox>
                                    <%--  <telerik:RadTextBox ID="RtbChkNumberinInsertMode" runat="server" EmptyMessage="Enter Reset Check NO "
                                        ValidationGroup="g">
                                    </telerik:RadTextBox>--%>
                                    <asp:RequiredFieldValidator ValidationGroup="g" ControlToValidate="RtbChkNumberinInsertMode"
                                        ID="ReqchkInsert" runat="server" ForeColor="Red">*</asp:RequiredFieldValidator>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                </td>
                                <td>
                                    <telerik:RadButton ID="RbtnOk" runat="server" Text="OK" OnClick="RbtnChkOkinInsert_Click">
                                    </telerik:RadButton>
                                    &nbsp;
                                    <telerik:RadButton ID="RbtnChkNumberCancelInpanel" runat="server" Text="Cancel" OnClientClicking="closeRadWindow2"
                                        Style="position: relative; top: -20px; left: 50px;">
                                    </telerik:RadButton>
                                </td>
                            </tr>
                        </table>
                    </ContentTemplate>
                </telerik:RadWindow>

    The above  Rad Window OK button is not ajaxified in that  situation, My page is post back happens ,i dint' want  post back of entire page ...but i am ajaxified ok button value is not transfer
     <telerik:GridTemplateColumn Visible="false" DataField="voidAfter" HeaderText="Void After"
                        HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" UniqueName="voidAfter">
                  
                        <ItemTemplate>
                            <%# Eval("voidAfter")%>
                        </ItemTemplate>
                        <InsertItemTemplate>
                            <telerik:RadTextBox ID="rdtxtvoidAfter2" runat="server" Text='<%# Eval("voidAfter") %>'
                                Width="160px" onclick="shouldConfirm = true;" ValidationGroup="g1" />
                        
                            <asp:RequiredFieldValidator ID="rvftxtvoidAfter2" runat="server" ForeColor="Red"
                                ControlToValidate="rdtxtvoidAfter2" ValidationGroup="g1" ErrorMessage="Void After is required."
                                Display="Dynamic" />
                            <asp:RegularExpressionValidator ID="rvgtxtvoidAfter2" runat="server" ForeColor="Red"
                                ValidationExpression="^\d+$" ErrorMessage="Allow Only Integer And Grater  Than 0"
                                ValidationGroup="g1" Display="Dynamic" ControlToValidate="rdtxtvoidAfter2" SetFocusOnError="true" />
                    
                        </InsertItemTemplate>
     </telerik:GridTemplateColumn>

    check.aspx.cs


     protected void RbtnChkOkinInsert_Click(object sender, EventArgs e)
        {
            foreach (GridEditFormItem item in RadGrid1.MasterTableView.GetItems(GridItemType.EditFormItem))
            {
                if (item.IsInEditMode)
                {
                    RadTextBox RtbCheckNumber = (RadTextBox)item.FindControl("rdtxtchkNumber1");
                    if (RtbChkNumberinInsertMode.Text != string.Empty)
                    {
                        RtbCheckNumber.Text = "";
                        RtbCheckNumber.Text = RtbChkNumberinInsertMode.Text;

                    }
                    else
                    {
                        RadWindowManager1.RadAlert("Reset Check Number Not Enter", 300, 60, "Check Details", null);
                    }
                }
            }

    }

    I want transfer the value of rad window in side  rad text-box  value  to grid inside  Rad Text-box ...but value is not transfer....page post that time value is transfer  to Rad Text box in side grid.
     
  7. Answer
    Danail Vasilev
    Admin
    Danail Vasilev avatar
    1492 posts

    Posted 04 Jun 2013 Link to this post

    Hello Sairam,

    The reason for your page to postback is that the autopostback property of the RadButton is not set to false (its default value is true). When you click the RadButton, a postback is performed and therefore the RadWindow is disposed as well as the values of the controls inside its content template.

    What I can suggest you is to follow the approach that my colleague has offered in his previous post:
    • set the AutoPostBack property of the button to false
    • use hiddenfields, in order to store the ClientIDs of the textboxes
    • use the OnClientClicked function of the button to transfer value from the textbox of the RadWindow to the textbox of the RadGrid.

    You can also find attached a modified version of your example with this approach.


    Regards,
    Danail Vasilev
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  8. Sairam
    Sairam avatar
    56 posts
    Member since:
    May 2013

    Posted 04 Jun 2013 Link to this post

    Thank You,Danail Vasilev.it's  perfectly working........Thank you once again for your support............telerik rocks......
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017