JScript error in delete option

2 posts, 0 answers
  1. Debashis Pyne
    Debashis Pyne avatar
    66 posts
    Member since:
    Apr 2010

    Posted 02 Feb 2011 Link to this post


    I have a radgrid, with a delete option as below:

    <telerik:RadScriptManager ID="RadScriptManager1" runat="server"></telerik:RadScriptManager>   
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
                <telerik:AjaxSetting AjaxControlID="pnlMaster">
                        <telerik:AjaxUpdatedControl ControlID="pnlMaster" />
    <telerik:RadGrid ID="grdCompanyList"
                    runat="server" GridLines="None"
                    AllowFilteringByColumn = "True"
                    OnItemCommand = "grdCompanyList_ItemCommand">
                    <PagerStyle Mode="NextPrevAndNumeric"></PagerStyle>                                
                    <MasterTableView DataKeyNames="watchlist_id" CommandItemDisplay="Top" EditMode="PopUp">
                    <CommandItemSettings ShowAddNewRecordButton="false"/>
                        <telerik:GridBoundColumn DataField="watchlist_id" DataType="System.Int32" 
                            HeaderText="watchlist_id" ReadOnly="True" SortExpression="watchlist_id" 
                            UniqueName="watchlist_id" Visible="false" >
                        <telerik:GridBoundColumn DataField="company_id" DataType="System.Int32" 
                            HeaderText="company_id" ReadOnly="True" SortExpression="company_id" 
                            UniqueName="company_id" Visible="false" >
                        <telerik:GridTemplateColumn AllowFiltering="false" ItemStyle-Width="180px">
                            <asp:Image width="142" height="58" ID="CompLogos" ImageUrl="<%# showCompLogo(Container.DataItem) %>"
                             runat="server" AlternateText="Logo" />
                        <telerik:GridBoundColumn DataField="company_name"
                            HeaderText="Company name" SortExpression="company_name" ItemStyle-Width="450"
                            UniqueName="company_name" ReadOnly="true">
                            <ItemStyle Width="450px" />
                        <telerik:GridTemplateColumn AllowFiltering="false" ItemStyle-Width="150px" HeaderText="Actions">
                                <span style="padding:0 5px">
                                    <asp:HyperLink ID="CoLink" runat="server" ImageUrl="~/images/viewicon_big.png"
                                    ToolTip="View Details"></asp:HyperLink>
                                <span style="padding:0 5px">                                
                                    <asp:ImageButton runat="server" ID="DelButton" ImageUrl="~/images/delete-32.png" ToolTip="Delete"
                                    CausesValidation="false" CommandName="Delete" />
                    <ClientSettings EnableRowHoverStyle="true"></ClientSettings>

    The following is the delete code in c#:

    protected void grdCompanyList_ItemCommand(object sender, GridCommandEventArgs e)
            if (e.CommandName == RadGrid.DeleteCommandName)
                GridDataItem item = (GridDataItem)e.Item;
                string iWatch = item["watchlist_id"].Text;
                Power50MiddleWare.BL.Watchlist oWatch = new Power50MiddleWare.BL.Watchlist();
                oWatch._WatchlistId = Int32.Parse(iWatch);
                    int retResult = oWatch.RemoveWatchlist();
                    if (retResult == 1)
                        pnlMsg.Visible = true;
                        lblMsg.Text = "Successfully deleted your watchlist item";
                        pnlMsg.Visible = true;
                        lblMsg.Text = "Sorry could not delete the item, please contact your system administrator";
                catch (System.Exception exp)
                    pnlMsg.Visible = true;
                    lblMsg.Text = exp.Message.ToString() + exp.StackTrace;

    However when i try this, i get an JS error as attached.

    Please suggest.


  2. Radoslav
    Radoslav avatar
    1564 posts

    Posted 03 Feb 2011 Link to this post

    Hello Debashis,

    Thank you for contacting us.

    This error occurs when the layout of the form being submitted differs from what has been defined on the server side and you have validation enabled. This is usually caused by adding new fields, or items to forms using client
    script, or the end user submits the form before the page has finished rendering because the server needs the following line
    <input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION"
    to be correctly rendered before submitting the form. It is a feature to stop people submitting their own forms to your ASP.net page. What I can suggest is to set the enableEventValidation property to false either in the page directive or in the Web.config. This should fix the problem but I also recommend to search the net for other possible solutions.

    If you need further assistance, do not hesitate to contact us again.

    Best wishes,
    the Telerik team
    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
Back to Top