我有一个gridview,在页面索引上我需要显示一个确认框警告,其中包含“确定”和“取消”。我在页面中有一个更新按钮,gridview有下拉值。当用户更改gridview中的下拉值并尝试移动到下一页而不单击更新按钮时,我需要显示一个警告,例如“确保在导航之前更新了更改”。我已经尝试了很多JS并没有任何帮助。
我在页面索引中使用了这段代码。弹出警报,但不会弹出确认框,显示确定和取消。
string script = "alert('Make sure you have updated the page before navigation!')";
ScriptManager.RegisterStartupScript(Page, Page.GetType(), "Alert", script, true);
我的代码:
<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true"
CodeFile="Application_Service_Sizing.aspx.cs" Inherits="Application_Service_Sizing" %>
<asp:content id="Content1" contentplaceholderid="head" runat="Server">
<div id="paging">
<asp:scriptmanager runat="server">
</asp:scriptmanager>
<asp:updatepanel runat="server">
<contenttemplate>
<asp:gridview id="GridView1" runat="server" allowpaging="True" onpageindexchanging="GridView_PageIndexChanging"
autogeneratecolumns="False" onrowdatabound="RowDataBound" pagesize="100" datakeynames="Products"
width="1000px" cssclass="manlog">
<asp:GridView ID="GridView1" runat="server">
<Columns>
<asp:BoundField DataField="tran_date" HeaderText="Transaction Date"
SortExpression="tran_date" />
<asp:BoundField DataField="RSQ" HeaderText="Transaction Cash"
SortExpression="RSQ" />
<asp:BoundField DataField="RSU" HeaderText="Cash Unit"
SortExpression="RSU" />
<asp:BoundField DataField="CSQ" HeaderText="Credit sale"
SortExpression="CSQ" />
<asp:BoundField DataField="CSU" HeaderText="Credit Unit"
SortExpression="CSU" />
<asp:BoundField DataField="iAmount" HeaderText="Amount"
SortExpression="iAmount" />
</Columns>
</asp:GridView>
</contenttemplate>
</asp:updatepanel>
</div>
</asp:content>
页面索引:
protected void GridView_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridView1.PageIndex = e.NewPageIndex;
}
真的很感激任何帮助。