1

This is how my Page headers look like :

<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.Master" AutoEventWireup="true" 
    CodeBehind="CategoryDetails.aspx.cs" Inherits="InventoryManagementSys.CategoryDetails" EnableEventValidation="false" %>

I have simple text boxes and one radio button list in my ContentPage, which looks like this :

<div class="input-group">
      <div class="row">
         <div class="col-md-9">Height/Width Apply ?</div>
         <asp:RadioButtonList ID="rblYN" runat="server" RepeatDirection="Horizontal">
              <asp:ListItem>Yes</asp:ListItem>
              <asp:ListItem>No</asp:ListItem>
         </asp:RadioButtonList>
      </div>
 </div>

My update button looks like this :

<asp:Button ID="btnUpdateDetails" CausesValidation="false"
 runat="server" CssClass="btn btn-primary"
 Text="Update Details" OnClick="btnUpdateDetails_Click" />

I update the details in my code behind like this :

protected void btnUpdateDetails_Click(object sender, EventArgs e)
    {
        Category catObj = new Category();

    catObj.CategoryName = txtName.Text;
    catObj.CategoryDescription = txtDesc.Text;
    catObj.HeightWidth = rblYN.SelectedValue;
    catObj.CategoryID = Convert.ToInt32(Request.QueryString["ID"]);

    int upd_result = new CategoryLogic().Update(catObj);

    if (upd_result > 0)
    {
        catObj.DateUpdated = DateTime.Now;

        int upd_date = new CategoryLogic().UpdateDate(catObj);

        if (upd_date > 0)
        {
            ScriptManager.RegisterStartupScript(btnUpdateDetails, btnUpdateDetails.GetType(), "key", string.Format("toastr['success']('{0} - was updated successfully!')", catObj.CategoryName), true);
        }
        else
        {
            ScriptManager.RegisterStartupScript(btnUpdateDetails, btnUpdateDetails.GetType(), "key", string.Format("toastr['error']('There was some error while updating record for - {0} - Category! Please try again!')", catObj.CategoryName), true);
        }
    }
    else
    {
        ScriptManager.RegisterStartupScript(btnUpdateDetails, btnUpdateDetails.GetType(), "key", string.Format("toastr['error']('There was some error while updating record for - {0} - Category! Please try again!')", catObj.CategoryName), true);
    }
}

I think my code look clean. Why is this error persistent ? I am not doing nothing new. This problem occurs while updating details.

EDIT:

As the answers to similar questions mentio that , this problem may arise because of the dynamically generated controls or some client side script... But I am not creating any dynamic controls except the text of the text boxes and the RadioButtonList selection!

In this way my problem is different than others!

Abhishek Ghosh
  • 2,593
  • 3
  • 27
  • 60

1 Answers1

1

In your master page you have 2 form tag.

  1. <form ID="form1" runat="server"></form>

2.<form method="Post"></form>

Omit <form method="post"> tag from master page and add EnableEventValidation="true" in your content page. Your problem will resolve.

Community
  • 1
  • 1
Rojalin Sahoo
  • 1,025
  • 1
  • 7
  • 18