I want to show alert Message when user tries to navigate between pages in Gridview.
If user navigates to next page I need to give an alert like "Make sure you updated the page before you move" and a pop up should display. If yes is clicked it should go to another page or if cancel is clicked it has to stay in the same page
Loading
Khargesh RajputPosted Jan 23, 2015, 4:44 AM
<script type = "text/javascript"> function Confirm() {
var confirm_value = document.createElement("INPUT");
confirm_value.type = "hidden";
confirm_value.name = "confirm_value";
if (confirm("Make sure you updated the page before you move?")) {
confirm_value.value = "Yes";
} else {
confirm_value.value = "No";
}
document.forms[0].appendChild(confirm_value);
}
script>
protected void grid_pageindexchanging(object sender, GridViewPageEventArgs e)
{
string confirmValue = Request.Form["confirm_value"];
if (confirmValue == "Yes")
{
fncBindGrid();
}
else
{
grid.PageIndex = e.NewPageIndex;
fncBindGrid();
}
}
Joginder BangerPosted Jan 23, 2015, 4:15 AM
{
if(e.NewPageIndex<1)
{string script = "";
ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert", script);
}
}
krisPosted Jan 23, 2015, 4:00 AM
Joginder BangerPosted Jan 22, 2015, 10:56 AM
protected void grid_pageindexchanging(object sender, GridViewPageEventArgs e)
{
string script = "";
ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert", script);
if(script(
{
// do stuff here.....
}
}