Hi
On hdfBookId.Value , hdfMobile i am getting above error
C#
public static void getPopUp()
{
BALBooks bALBooks = new BALBooks();
BALStudents bALStudents = new BALStudents();
StudentDetail Result = bALStudents.GetStudentDetailByLoginID(bALStudents.GetStudentIDByMobile(hdfMobile.Value));
BindData(Convert.ToInt32(hdfBookId.Value), Result.LoginCode);
}Thanks

Naimish MakwanaRank #324 · 7.7K reputationPosted May 17, 2023, 4:33 AM EDT
You need to access variable like this:
public static void getPopUp() { YourClassName instance = new YourClassName(); // Access the variables through the instance var mobileValue = instance.hdfMobile.Value; var bookIdValue = instance.hdfBookId.Value; // Your code here }Thanks
Ramco RamcoRank #462 · 5.4K reputationPosted May 17, 2023, 4:36 AM EDT
Hi Naimish
Below is the Script. What should i change
function GetModuleData(e) { var currentRow = $(e).closest("tr"); var rp; // rp = currentRow.find("td:eq(0)").text(); var table = document.getElementById("grdPlanning"), rIndex, cIndex, track; // table rows for (var i = 1; i 0) { Mobile = $('table tr th:eq(' + (cIndex) + ')').text(); BookId = currentRow.find("td:eq(0)").text(); var str = Mobile; const result = str.split(/[()]/); var res1 = result[0]; var res2 = result[1]; document.getElementById('hdfBookId').value = BookId; document.getElementById('hdfMobile').value = res2; }; }; } } }; $.ajax({ type: "POST", url: "AddRecommendedBooks.aspx/getPopUp", /* *//*data: JSON.stringify({ bookId: BookId, mobile: res2 }),*/ contentType: "application/json; charset=utf-8", dataType: "json", success: function (response) { // Handle the response if needed console.log("C# code executed successfully."); }, error: function (xhr, textStatus, errorThrown) { // Handle the error if needed console.log("Error executing C# code:", errorThrown); } });Thanks
Naimish MakwanaRank #324 · 7.7K reputationPosted May 17, 2023, 4:39 AM EDT
Based on the provided script, it seems that you're trying to access the values of
hdfBookIdandhdfMobileelements in the JavaScript code. However, since those elements are usually server controls in ASP.NET, you need to make sure they have unique ClientID values when rendered on the client-side.function GetModuleData(e) { var currentRow = $(e).closest("tr"); var rp; // rp = currentRow.find("td:eq(0)").text(); var table = document.getElementById("grdPlanning"), rIndex, cIndex, track; // table rows for (var i = 1; i 0) { Mobile = $('table tr th:eq(' + (cIndex) + ')').text(); BookId = currentRow.find("td:eq(0)").text(); var str = Mobile; const result = str.split(/[()]/); var res1 = result[0]; var res2 = result[1]; document.getElementById('').value = BookId; document.getElementById('').value = res2; } }; } } } $.ajax({ type: "POST", url: "AddRecommendedBooks.aspx/getPopUp", /* *//*data: JSON.stringify({ bookId: BookId, mobile: res2 }),*/ contentType: "application/json; charset=utf-8", dataType: "json", success: function (response) { // Handle the response if needed console.log("C# code executed successfully."); }, error: function (xhr, textStatus, errorThrown) { // Handle the error if needed console.log("Error executing C# code:", errorThrown); } });Ramco RamcoRank #462 · 5.4K reputationPosted May 17, 2023, 4:47 AM EDT
Hi Naimish
I have changed but Ajax part is not getting executed.
Secondly what should i change to pass values to BinData()
Thanks