您好我试图重定向到gridView事件的另一个页面:selectedIndexChanged。我不想设置EnableEventValidation =" false"。
这是我的代码
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
llenarGridViewClientes();
}
}
protected void GridViewUsuarios_SelectedIndexChanged(object sender, EventArgs e)
{
Session["UsuarioHistoria"] = GridViewUsuarios.SelectedValue;
Response.Redirect("Historia.aspx");
}
并且页面:
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<div class="form-group">
<div class="input-group">
<asp:TextBox ID="txtBuscador" runat="server" CssClass="form-control" ></asp:TextBox>
<span class="input-group-btn">
<asp:Button ID="btnBuscar" runat="server" CssClass="btn btn-primary " Text="Buscar" OnClick="btnBuscar_Click"/>
</span>
</div>
</div>
<div id="divGrid" style="overflow: auto; height: 430px" >
<asp:GridView ID="GridViewUsuarios" runat="server" AutoGenerateColumns="False" AllowSorting="True" CellPadding="1" CssClass="table table-striped table-hover" GridLines="None" ShowHeaderWhenEmpty="True" ForeColor="#333333"
DataKeyNames="id" AllowPaging="False" Font-Names="Arial" Font-Size="Small" OnSelectedIndexChanged="GridViewUsuarios_SelectedIndexChanged">
<AlternatingRowStyle BackColor="White" />
<Columns>
<asp:CommandField ShowSelectButton="True" SelectText="Seleccionar" />
<asp:BoundField DataField="id" HeaderText="id" SortExpression="id" InsertVisible="False" ReadOnly="True" Visible="false" />
<asp:BoundField DataField="nombre" HeaderText="Nombre" SortExpression="nombre" />
<asp:BoundField DataField="apellido" HeaderText="Apellido" SortExpression="apellido" />
<asp:BoundField DataField="telefono" HeaderText="Telefono" SortExpression="telefono" />
<asp:BoundField DataField="celular" HeaderText="Celular" SortExpression="celular" />
<asp:BoundField DataField="dni" HeaderText="DNI" SortExpression="dni" />
</Columns>
<EditRowStyle BackColor="#2461BF" />
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#EFF3FB" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#F5F7FB" />
<SortedAscendingHeaderStyle BackColor="#6D95E1" />
<SortedDescendingCellStyle BackColor="#E9EBEF" />
<SortedDescendingHeaderStyle BackColor="#4870BE" />
</asp:GridView>
</div>
</asp:Content>
这是母版页。
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<asp:Timer ID="tmrRelojInterno" runat="server" OnTick="tmrRelojInterno_Tick1" Interval="1000"></asp:Timer>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="tmrRelojInterno" EventName="Tick" />
</Triggers>
<ContentTemplate>
<asp:Image ID="Image1" runat="server" ImageUrl="~/logo.png" ImageAlign="Middle" Height="159px" with="934px" />
<div style="display: inline-block">
<p>
<asp:Label ID="lbldia" runat="server" Font-Names=" arial" Font-Size="Medium" ForeColor="black" Font-Bold="True"></asp:Label>
</p>
<p>
<asp:Label ID="lblReloj" runat="server" Font-Names="arial" Font-Size="XX-Large"></asp:Label>
</p>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</div>
<div class="navbar navbar-inverse">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-inverse-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div class="navbar-collapse collapse navbar-inverse-collapse">
<ul class="nav navbar-nav">
<li><a href="Turnos.aspx">Turnos</a></li>
<li><a href="ClienteHistoriaClinica.aspx">Historia Clinica</a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Datos <b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="Usuarios.aspx">Usuarios</a></li>
<li><a href="Profesiones.aspx">Profesiones</a></li>
<li><a href="Clientes.aspx">Clientes</a></li>
<li><a href="Servicios.aspx">Servicios</a></li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Consultar <b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="TurnosEliminados.aspx">Turnos Eliminados</a></li>
</ul>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<p class="navbar-text">
<asp:LoginView ID="LoginView1" runat="server" EnableViewState="false">
<LoggedInTemplate>
<asp:LoginName ID="HeadLoginName" runat="server" Font-Bold="False" Font-Size="12" ForeColor="White" />
[
<asp:LoginStatus ID="HeadLoginStatus" runat="server" LogoutAction="Redirect" LogoutText="Cerrar sesión" LogoutPageUrl="~/" Font-Bold="False" Font-Size="12" ForeColor="White" />
]
</LoggedInTemplate>
</asp:LoginView>
</p>
</ul>
</div>
</div>
<div class="container-fluid">
<div class="row">
<div class="col-lg-2 ">
<asp:ContentPlaceHolder ID="content3" runat="server">
</asp:ContentPlaceHolder>
</div>
<div class="col-lg-6 ">
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</div>
<div class="col-lg-4">
<asp:ContentPlaceHolder ID="ContentPlaceHolder2" runat="server"></asp:ContentPlaceHolder>
</div>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
</form>
</body>
这是堆栈跟踪
[ArgumentException:无效的回发或回调参数。事件 使用in启用验证 配置或&lt;%@ Page EnableEventValidation =&#34; true&#34; %GT;在一个页面中。 出于安全考虑,此功能会验证参数 回发或回调事件源自服务器控件 最初渲染它们。如果数据有效且预期,请使用 ClientScriptManager.RegisterForEventValidation方法 注册回发或回调数据以进行验证。]
System.Web.UI.ClientScriptManager.ValidateEvent(String uniqueId, 字符串参数)+144
System.Web.UI.WebControls.TextBox.LoadPostData(String postDataKey, NameValueCollection postCollection)+126
System.Web.UI.WebControls.TextBox.System.Web.UI.IPostBackDataHandler.LoadPostData(字符串 postDataKey,NameValueCollection postCollection)+13
System.Web.UI.Page.ProcessPostData(NameValueCollection postData, 布尔值fBeforeLoad)+303
System.Web.UI.Page.ProcessRequestMain(布尔 includeStagesBeforeAsyncPoint,Boolean includeStagesAfterAsyncPoint) 1960
答案 0 :(得分:0)
尝试将[YourFormName].Action = Request.RawURL;
添加到母版页的page_load事件中,以便为我解决此问题。