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

Radbutton inside asp.repeater get_id Container.Dataitem

1 Answer 230 Views
Button
This is a migrated thread and some comments may be shown as answers.
steve
Top achievements
Rank 2
steve asked on 23 Sep 2016, 12:20 AM

I would like to see if it's possible to pass the value from a container.data with rad button in an asp.repeater control.

 

<script type="text/javascript">
function open_windowtemplate_AddSection(sender, args) {
var button = sender.get_id();
alert($(button).commandarguments);
}
</script>

 

<asp:Repeater ID="rpt_Channel" runat="server" OnItemDataBound="rpt_Channel_ItemDataBound">
<ItemTemplate>
<tr>
<td colspan="4" class="MainLineItem">
<div style="float:left;">&#9632; <asp:Label ID="lbl_ChapterName" runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "Chapter")%>'></asp:Label></div>
<div style="float:right">
<asp:ImageButton ID="imgbtn_AddSection" runat="server" AlternateText="Click to add section" ImageUrl="~/Includes/images/green_plus_add.png" Height="20px" CommandName="Add" />
<telerik:RadButton ID="radbutton_AddSection" runat="server" Text="+" CommandArgument='<%Databinder.Eval(Container.DataItem, "Channel_ID") %>'
ButtonType="StandardButton" OnClientClicked='open_windowtemplate_AddSection' AutoPostBack="false">
</telerik:RadButton>

1 Answer, 1 is accepted

Sort by
0
Accepted
Ianko
Telerik team
answered on 27 Sep 2016, 10:17 AM

Hello Steve,

 

I am not sure what is the exact difficulty with the case here. 

 

The only issues I see is the alerted value in the open_windowtemplate_AddSection click hander of RadButton. And they are:

 

  1.  $(button) would not return you the proper jQuery element. get_id returns you only the id, not the selector to use for jQuery. Make sure to modify that so that it works. For example, $("#" + button).
  2. Even if you get the proper jQuery element there is no commandarguments property that would return you the CommandArgument assigned in the RadButton control. 

    For that, there is the client-side API of the RadButton reference: http://docs.telerik.com/devtools/aspnet-ajax/controls/button/client-side-programming/overview. And the method is get_commandArgument().

    I suggest you testing with this piece of code:
    function open_windowtemplate_AddSection(sender, args) {
        alert(sender.get_commandArgument());
    }

If this does not help you with the case. Please, provide a simple, locally runnable markup of the situation you have and elaborate more on the difficulty you have with it.

Regards,

Ianko
Telerik by Progress
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Tags
Button
Asked by
steve
Top achievements
Rank 2
Answers by
Ianko
Telerik team
Share this question
or