Hi
I am getting error - 'mbox_ascx' does not contain a definition for 'lnkRecordDelete_Click' and no accessible extension method 'lnkRecordDelete_Click' accepting a first argument of type 'mbox_ascx' could be found (are you missing a using directive or an assembly reference?)
JavaScript
var swalInit = swal.mixin({
buttonsStyling: false,
confirmButtonClass: 'btn btn-primary',
cancelButtonClass: 'btn btn-light'
});
function ShowPopup_Redirect(heading, body, type, url) {
swalInit.fire({
title: heading,
text: body,
type: type,
position: 'top',
allowOutsideClick: false;
}
});
}
×
Cancel
DeleteC#
protected void lnkRecordDelete_Click(object sender, EventArgs e)
{
try
{
if (hdfId.Value != "0")
{
try
{
using (SqlConnection con = new SqlConnection(Common.CommonFunction.cnn_Live))
{
SqlCommand cmd = new SqlCommand("sp_EmployeeCategory", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@DocEntryNo", SqlDbType.Int).Value = hdfId.Value;
cmd.Parameters.Add("@Action", SqlDbType.NVarChar).Value = "D";
cmd.Parameters.AddWithValue("@UpdatedBy", SqlDbType.Int).Value = Convert.ToInt32(hdfLoginId.Value);
SqlParameter successParam = cmd.Parameters.Add("@Success", SqlDbType.Bit);
successParam.Direction = ParameterDirection.Output;
con.Open();
cmd.ExecuteNonQuery();
bool success = (bool)successParam.Value;
if (success)
{
string message = Common.CommonFunction.recordDeletedSucessfully;
ShowMessage("", message, "Success");
}
else
{
ShowMessage("Oops...", success.ToString(), "error");
}
GetData();
}
}
catch (Exception ex)
{
ShowMessage("Oops...", ex.Message, "error");
}
}
else
{
ShowMessage("Error", "Record Delete Failed, Please Try Again", "error");
GetData();
}
}
catch (Exception ex)
{
ShowMessage("Oops...", ex.Message, "error");
GetData();
}
}Thanks

Gowtham CpRank #1,552 · 1K reputationPosted Aug 26, 2024, 12:46 AM EDT
If the lnkRecordDelete_Click method isn’t being recognized, start by checking that it’s properly defined in your MBox.ascx.cs file and that the Inherits attribute in your .ascx file matches this class. Rebuilding the project can sometimes clear up these issues, so give that a try if things still aren’t working. Lastly, make sure all your file names and paths are correct. If you’re still running into trouble, just let me know and I’ll be happy to help further!
Ramco RamcoRank #462 · 5.4K reputationPosted Aug 26, 2024, 1:24 AM EDT
Hi Gowtham
In I have below code ony. I am sharing with you full code
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace Payroll { public partial class MBox : System.Web.UI.UserControl { protected void Page_Load(object sender, EventArgs e) { } } } ********************* var swalInit = swal.mixin({ buttonsStyling: false, confirmButtonClass: 'btn btn-primary', cancelButtonClass: 'btn btn-light' }); function ShowPopup(heading, body, type) { swalInit.fire({ /* title: `${heading} `,*/ /*title: `${heading} `,*/ title: ` ${heading} `, html: `${body} `, icon: type, position: 'center', // Adjust position as needed allowOutsideClick: false, confirmButtonText: 'OK', timer: 6000 }); } function ShowPopup_Redirect(heading, body, type, url) { swalInit.fire({ title: heading, text: body, type: type, position: 'top', allowOutsideClick: false, onClose: function () { location.href = url; } }); } × Cancel Delete--%>EmploueeCategory.aspx.cs ------------------ protected void lnkRecordDelete_Click(object sender, EventArgs e) { try { if (hdfId.Value != "0") { try { using (SqlConnection con = new SqlConnection(Common.CommonFunction.cnn_Live)) { SqlCommand cmd = new SqlCommand("sp_EmployeeCategory", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@DocEntryNo", SqlDbType.Int).Value = hdfId.Value; cmd.Parameters.Add("@Action", SqlDbType.NVarChar).Value = "D"; cmd.Parameters.AddWithValue("@UpdatedBy", SqlDbType.Int).Value = Convert.ToInt32(hdfLoginId.Value); SqlParameter successParam = cmd.Parameters.Add("@Success", SqlDbType.Bit); successParam.Direction = ParameterDirection.Output; con.Open(); cmd.ExecuteNonQuery(); bool success = (bool)successParam.Value; if (success) { string message = Common.CommonFunction.recordDeletedSucessfully; ShowMessage("", message, "Success"); } else { ShowMessage("Oops...", success.ToString(), "error"); } GetData(); } } catch (Exception ex) { ShowMessage("Oops...", ex.Message, "error"); } } else { ShowMessage("Error", "Record Delete Failed, Please Try Again", "error"); GetData(); } } catch (Exception ex) { ShowMessage("Oops...", ex.Message, "error"); GetData(); } }Thanks