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

    Hi,

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

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

    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);
                try
                {
                    int retResult = oWatch.RemoveWatchlist();
                    if (retResult == 1)
                    {
                        GenerateWatchlist();
                        pnlMsg.Visible = true;
                        lblMsg.Text = "Successfully deleted your watchlist item";
                    }
                    else
                    {
                        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.

    Thanks,

    Debashis
  2. Radoslav
    Admin
    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"
    value="somestringofgiberish"
    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,
    Radoslav
    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top