Execute JavaScript code on GridView SelectedIndexChanged event using jQuery in ASP.Net

Last Reply on May 04, 2017 06:37 AM By alya14

Posted on May 03, 2017 05:59 PM

the below code is working if I call in button OnclientClick But not working if I call in  gridview SelectedIndexChanged event

function Confirm()
{
     var confirmValue = document.createElement("INPUT");
     confirmValue.type = "hidden";
     confirmValue.name = "confirm_value";

     if (confirm("Process Staring ?"))
     {
           confirmValue.value = "Yes";
           document.forms[0].appendChild(confirmValue);
     }
     else
     {
           confirmValue.value = "No";
           document.forms[0].appendChild(confirmValue);
      }
}

Controls.Add(new LiteralControl("<script type='text/javascript'>return Confirm();</script>"));
string confirmValue = Request.Form["confirm_value"];        
if (confirmValue == "Yes")
{
     ClientScript.RegisterStartupScript(Page.GetType(), "validation", "<script language='javascript'>alert('Yes')</script>");
          
}
else 
{
     ClientScript.RegisterStartupScript(Page.GetType(), "validation", "<script language='javascript'>alert('No')</script>");
}
You are viewing reply posted by: alya14 on May 04, 2017 06:37 AM.
Posted on May 04, 2017 06:37 AM

Thank you so much .