how to get the text of a linkbutton(Linkbutton is in a repeater control) that is right clicked? RRS feed

  • Question

  • I am developeing a web application in asp.net.In my application I have a form which contains a Repeater control.In repeater I am using a linkbutton. The link button text comes from database.I have used a javascript to display a contextmenu when a link button is rightclicked. The contextmenu contains options like "Create","Update" and "Delete". So when any of the context menu item is clicked a modelpopup will be displayed. Till this part it worked fine, my problem is "I want the linkbutton text on which i have made rightclick", because i need to use the linkbutton text in the modelpopup.

    The following is my repeater.And the javascript is for displaying conextmenu on right click of linkbutton

        <asp:Repeater ID="Repeater1" runat="server" onitemdatabound="Repeater1_ItemDataBound">
        <asp:LinkButton ID="context" runat="server" CssClass ="folder" oncontextmenu="javascript:return oCustomContextMenu.Display(event);" onclick="context_Click" />

     protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
            if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
                string culture = e.Item.DataItem as string;
                LinkButton hypCulture = e.Item.FindControl("context") as LinkButton;
                hypCulture.Text = culture;

    The javascript which i got from net is working fine for me.The following is js

        <script type="text/javascript">
        var oCustomContextMenu = null;
        var oBase = null;
        window.onload = function () {
        oBase = document.getElementById('div');
        var Arguments = {
                    Base: oBase,
                    Width: 200,
                    FontColor: null,
                    HoverFontColor: null,
                    HoverBackgroundColor: null,
                    HoverBorderColor: null,
                    ClickEventListener: OnClick

                oCustomContextMenu = new CustomContextMenu(Arguments);
                oCustomContextMenu.AddItem('Images/ei0019-48.gif', 'Create', false, 'Create');
                oCustomContextMenu.AddItem('Images/ei0020-48.gif', 'Update', false, 'Update');
                oCustomContextMenu.AddItem('Images/Delete-icon.png', 'Delete', false, 'Delete');
            var OnClick = function (Sender, EventArgs) {
                switch (EventArgs.CommandName) {
                    case 'Create':
                    case 'Update':
                    case 'Delete':


            window.onunload = function () { oCustomContextMenu.Dispose(); }

    The following is used for displaying model popup on context menu item click

        <asp:ModalPopupExtender ID="FstModelPopUp" runat="server" TargetControlID="BtnFstModelPopUp" PopupControlID ="PnlFstModelPopUp"
        Drag="true" DropShadow ="true" BackgroundCssClass="modalBackground" CancelControlID="btncancel">

    Now i want to use the rightclicked linkbutton text in the modelpopup..how to do that

    Please provide me solution with example

    Tuesday, March 26, 2013 5:30 AM


All replies