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

RadMenu server side event ItemClick event handler not fired

0 Answers 132 Views
UI for ASP.NET AJAX in ASP.NET MVC
This is a migrated thread and some comments may be shown as answers.
Ragha
Top achievements
Rank 1
Ragha asked on 15 Oct 2012, 06:48 AM
Hi All,


I have a RadGrid for which radMenu is bound as context menu
the grid displays the items such as PersonFirstname,PersonLastname,emailid
when i click on emailid the context menu with the options
Copy,paste,... gets displayed.


for example when i click on someone@somemail.com
it displays copy,paste,edit,...
when i click on copy i need the "someone@somemail.com" value either in javascript or server side event

My javascript function is below

 function OnClientItemClickedHandler(sender, eventArgs)
    {   
        var personid, txt, lsreturnval;
             
        txt = eventArgs.Item.Text
        lsreturnval = '0'
        personid = document.getElementById("<%=hdnPersonID.ClientID %>").value
        try
        {
            if (txt == 'View/Edit Contact')
                lsreturnval=window.showModalDialog('../Contact/Editcontact.aspx?person_id='+personid+'&Mode=EDIT','EditContact','dialogWidth:'+editWidth+'px;dialogHeight:'+editHeight+'px;status:no;help:no;resizable:no;scroll:yes;maximize:no');
            else if (txt == 'Add')
                lsreturnval=window.showModalDialog('../Contact/Editcontact.aspx?Person_id='+personid+'&Mode=ADD','','dialogWidth:'+editWidth+'px;dialogHeight:'+editHeight+'px;status:no;help:no;resizable:no;scroll:yes;maximize:no');
            else if (txt == 'Copy')
            {   
            /// the code must go here
            }     

                
            else if (txt == 'Delete')
                if(!confirm('Are you sure you wish to delete company contact Relationship ?'))
                {
                    <%=mnuCompanyContact.ClientID%>.OnClientItemClickedHandler=OnClientItemClickedHandler;
                    return false;
                }
                else
                    return true;
                
            if (lsreturnval!='1')
            {
                <%=mnuCompanyContact.ClientID%>.OnClientItemClickedHandler=OnClientItemClickedHandler;
                return false;
            }
            
        }
        catch (err)
        {
            <%=mnuCompanyContact.ClientID%>.OnClientItemClickedHandler=OnClientItemClickedHandler;
            return false;
        }
       
    }

serverside .vb code

Protected Sub mnuCompanyContact_ItemClick(ByVal sender As Object, ByVal e As Telerik.WebControls.RadMenuEventArgs) Handles mnuCompanyContact.ItemClick
        Try
            If e.Item.Text.ToString.ToUpper = "COPY" Then
                GetComPanyContact(hdnCompanyId.Value)
            ElseIf e.Item.Text.ToString.ToUpper = "VIEW/EDIT CONTACT" Then
                GetComPanyContact(hdnCompanyId.Value)
            ElseIf e.Item.Text.ToString.ToUpper = "ADD" Then
                GetComPanyContact(hdnCompanyId.Value)
            ElseIf e.Item.Text.ToString.ToUpper = "DELETE" Then
                DeleteCompanyContact(hdnContactID.Value)
            End If
        Catch ex As Exception
            'TODO: Error Handler
            CUtility.PageErrorHandler(Err.Number, ex, "Event mnuCompanyContact_ItemClick")
        End Try
    End Sub


the above event never gets fired.



the markup code(.aspx)

  <radG:RadGrid ID="grdCompanyContacts" runat="server" AutoGenerateColumns="False"
                        EnableAJAX="False" GridLines="None" Width="100%" Skin="eCrm" AllowSorting="true"
                        EnableAJAXLoadingTemplate="true" LoadingTemplateTransparency="20" BorderStyle="None"
                        BorderWidth="0px" CellPadding="0" CellSpacing="1"  HeaderStyle-BackColor="#818A8F">
                        <%--AllowPaging="True" PageSize="20"--%>
                        <ItemStyle BorderStyle="None" Height="20px" />
                        <AlternatingItemStyle BorderStyle="None" Height="20px" />
                        <HeaderStyle  CssClass="grid_head1" />
                        <ClientSettings EnableClientKeyValues="True">
                            <Selecting AllowRowSelect="True" />
                            <ClientEvents OnRowContextMenu="RCM2" OnRowSelected="RS2" />
                            <Scrolling AllowScroll="True" UseStaticHeaders="True" ScrollHeight="250px" />
                        </ClientSettings>
                        <MasterTableView EditMode="InPlace" Width="100%" DataKeyNames="PERSON_ID">
                            <NoRecordsTemplate>
                            </NoRecordsTemplate>
                            <Columns>
                                <radG:GridBoundColumn DataField="PERSON_ID" Visible="False" UniqueName="colPersonID" />
                                <radG:GridBoundColumn DataField="ASSOCIATED_COMPANY_COUNT" Visible="False" UniqueName="colASSOCIATED_COMPANY_COUNT" />
                                <radG:GridTemplateColumn UniqueName="colControls">
                                    <HeaderStyle Width="4%" />
                                    <ItemTemplate>
                                        <asp:ImageButton runat="Server" ToolTip="Edit Contact" ID="imgEdit" OnClick="UpdateCompanyContactGrid"
                                            ImageUrl="../Images/edit.gif" />
                                        <asp:ImageButton runat="Server" ToolTip="Delete Contact" ID="imgDelete" ImageUrl="../Images/Delete_Rec.gif"
                                            OnClick="imgOnClick_DeleteCompanyContact" />
                                    </ItemTemplate>
                                </radG:GridTemplateColumn>
                                <radG:GridTemplateColumn HeaderText="Name" SortExpression="contact_name" UniqueName="contact_name">
                                    <HeaderStyle Width="20%" />
                                    <ItemTemplate>
                                        <a class="gray" href="../contact/Contact.aspx?Person_id=<%# DataBinder.Eval(Container.DataItem,"person_id") %>">
                                            <%#DataBinder.Eval(Container.DataItem, "CONTACT_NAME")%>
                                        </a>
                                    </ItemTemplate>
                                </radG:GridTemplateColumn>
                                <radG:GridBoundColumn DataField="TITLE" HeaderText="Title" SortExpression="TITLE"
                                    Resizable="False" UniqueName="column1">
                                    <HeaderStyle Width="20%" />
                                    <ItemStyle HorizontalAlign="Left" Wrap="False" />
                                </radG:GridBoundColumn>
                                <radG:GridTemplateColumn HeaderText="Office" SortExpression="company_name" UniqueName="company_name">
                                    <HeaderStyle Width="20%" />
                                    <ItemTemplate>
                                        <a  class="gray" href="../company/Company.aspx?Company_Id=<%# DataBinder.Eval(Container.DataItem,"COMPANY_ID") %>&Office_Id=<%# DataBinder.Eval(Container.DataItem,"COMPANYID") %>">
                                            <%# DataBinder.Eval(Container.DataItem,"COMPANY_NAME") %>
                                        </a>
                                    </ItemTemplate>
                                </radG:GridTemplateColumn>
                                <radG:GridBoundColumn DataField="address" Visible="False" SortExpression="address"
                                    HeaderText="Address" Resizable="False" UniqueName="column1">
                                    <ItemStyle HorizontalAlign="Left" Wrap="False" />
                                    <HeaderStyle Width="20%" />
                                </radG:GridBoundColumn>
                                <radG:GridBoundColumn DataField="city" SortExpression="city" Visible="False" HeaderText="City"
                                    Resizable="False" UniqueName="column1">
                                    <ItemStyle HorizontalAlign="Left" Wrap="False" />
                                    <HeaderStyle Width="20%" />
                                </radG:GridBoundColumn>
                                <radG:GridTemplateColumn HeaderText="Email" SortExpression="EMAIL" UniqueName="E-Mail">
                                    <HeaderStyle Width="15%" />
                                    <ItemTemplate>
                                        <%# DataBinder.Eval(Container.DataItem,"EMAIL_INVALID") %>
                                        <a class="gray" href="mailto:<%# DataBinder.Eval(Container.DataItem,"EMAIL") %>">
                                            <%# DataBinder.Eval(Container.DataItem,"EMAIL") %>
                                        </a>
                                    </ItemTemplate>
                                </radG:GridTemplateColumn>
                                <radG:GridTemplateColumn UniqueName="Tel" HeaderText="Tel">
                                    <HeaderStyle Width="25%" />
                                    <ItemTemplate>
                                        <%# DataBinder.Eval(Container.DataItem,"PHONE_NUMBER_INVALID") %>
                                        <%# DataBinder.Eval(Container.DataItem,"PHONE_NUMBER") %>
                                    </ItemTemplate>
                                </radG:GridTemplateColumn>
                            </Columns>
                            <ExpandCollapseColumn Visible="False" Resizable="False">
                                <HeaderStyle Width="20px" />
                            </ExpandCollapseColumn>
                            <RowIndicatorColumn Visible="False">
                                <HeaderStyle Width="20px" />
                            </RowIndicatorColumn>
                        </MasterTableView>
                        <ExportSettings>
                            <Pdf PageBottomMargin="" PageFooterMargin="" PageHeaderMargin="" PageHeight="11in"
                                PageLeftMargin="" PageRightMargin="" PageTopMargin="" PageWidth="8.5in" />
                        </ExportSettings>
                        <PagerStyle Visible="false" />
                    </radG:RadGrid>
                      <telerik:RadScriptManager ID="ScriptManager" runat="server" />
                    <radM:RadMenu ID="mnuCompanyContact" runat="server" IsContext="True" OnClientItemClicking="OnClientItemClickedHandler"
                        ContextMenuElementID="none" Skin="eRebalContextMenu" OnItemDataBound="mnuCompanyContact_ItemDataBound" OnItemClick="mnuCompanyContact_ItemClick" Height="73px" Width="119px">
                        <Items>
                            <radM:RadMenuItem ID="RadMenuItem10" runat="server" Text="Copy">
                            </radM:RadMenuItem>
                            <radM:RadMenuItem ID="RadMenuItem8" runat="server" Text="View/Edit Contact">
                            </radM:RadMenuItem>
                            <radM:RadMenuItem ID="RadMenuItem5" runat="server" Text="Add">
                            </radM:RadMenuItem>
                            <radM:RadMenuItem ID="RadMenuItem11" runat="server" Text="Delete">
                            </radM:RadMenuItem>
                        </Items>
                    </radM:RadMenu>


I have been struck for 4 to 5 days
please help me
any help would be greatly appreciated.


Regards,
Sudha

No answers yet. Maybe you can help?

Tags
UI for ASP.NET AJAX in ASP.NET MVC
Asked by
Ragha
Top achievements
Rank 1
Share this question
or