A
ABHIJIT B
Hi All,
I am calling Code behind file function in one of JavaScript method as
given below,
I don't want to call Code behind file function during Page Load.
Kindly help me out for same.
I tried to call btnDelete.Attributes.Add("onclick",
"javascript:vDelete();");
in if(IsPostBack) and if(!IsPostBack).Still Code Behind function is
called.
---------------------------------------------------------------------------------------------------------------
ASPX Code :
function vDelete()
{
debugger;
window.alert("Hi");
var loginid = document.getElementById('<
%=txtCFirstName.ClientID%>').value;
window.alert(loginid);
if(loginid == '')
{
window.alert("Hello");
document.getElementById('<%=hidUserDel.ClientID%>').value =
"N";
return false;
}
else
{
var ret = window.confirm('Are you sure you want to delete this
record?');
window.alert(ret);
document.getElementById('<%=lblMUSaveError.ClientID
%>').innerHTML = "";
if(ret == true)
{
window.alert("Fine");
document.getElementById('<%=hidUserDel.ClientID%>').value =
"Y";
<%DeleteUser();%>;
return true;
}
else
{
window.alert("Hello");
document.getElementById('<%=hidUserDel.ClientID%>').value =
"N";
return false;
}
}
}
---------------------------------------------------------------------------------------------------------------------------
Code Behind File :
protected void Page_Load(object sender, EventArgs e)
{
if(!IsPostBack)
{
//code
btnDelete.Attributes.Add("onclick",
"javascript:vDelete();");
}
}
protected void DeleteUser()
{
try
{
if (hidSave.Value.ToString() == "0")
gvUsersList.Rows[0].Cells.Clear(); //GridView
}
catch(Exception ex)
{
//Loggin error in txt file
}
}
I am calling Code behind file function in one of JavaScript method as
given below,
I don't want to call Code behind file function during Page Load.
Kindly help me out for same.
I tried to call btnDelete.Attributes.Add("onclick",
"javascript:vDelete();");
in if(IsPostBack) and if(!IsPostBack).Still Code Behind function is
called.
---------------------------------------------------------------------------------------------------------------
ASPX Code :
function vDelete()
{
debugger;
window.alert("Hi");
var loginid = document.getElementById('<
%=txtCFirstName.ClientID%>').value;
window.alert(loginid);
if(loginid == '')
{
window.alert("Hello");
document.getElementById('<%=hidUserDel.ClientID%>').value =
"N";
return false;
}
else
{
var ret = window.confirm('Are you sure you want to delete this
record?');
window.alert(ret);
document.getElementById('<%=lblMUSaveError.ClientID
%>').innerHTML = "";
if(ret == true)
{
window.alert("Fine");
document.getElementById('<%=hidUserDel.ClientID%>').value =
"Y";
<%DeleteUser();%>;
return true;
}
else
{
window.alert("Hello");
document.getElementById('<%=hidUserDel.ClientID%>').value =
"N";
return false;
}
}
}
---------------------------------------------------------------------------------------------------------------------------
Code Behind File :
protected void Page_Load(object sender, EventArgs e)
{
if(!IsPostBack)
{
//code
btnDelete.Attributes.Add("onclick",
"javascript:vDelete();");
}
}
protected void DeleteUser()
{
try
{
if (hidSave.Value.ToString() == "0")
gvUsersList.Rows[0].Cells.Clear(); //GridView
}
catch(Exception ex)
{
//Loggin error in txt file
}
}