分页错误我收到此错误 [英] paging Error i got this Error

查看:57
本文介绍了分页错误我收到此错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

,当我单击1,2,3,4,--- 10页时,每次单击1,2,3,当您单击第二页时,网格中的10页出现此错误.

in my GridView paging 10 pages in my grid when ever click the 1,2,3,4, ---10 pages when ever click the grid pages foreword in 1,2,3, when ever click the 2nd page i am getting this error.

Description: Request Validation has detected a potentially dangerous client input value, and processing of the request has been aborted. This value may indicate an attempt to compromise the security of your application, such as a cross-site scripting attack. To allow pages to override application request validation settings, set the requestValidationMode attribute in the httpRuntime configuration section to requestValidationMode="2.0". Example: <httpruntime requestvalidationmode="2.0" />. After setting this value, you can then disable request validation by setting validateRequest="false" in the Page directive or in the <pages> configuration section. However, it is strongly recommended that your application explicitly check all inputs in this case. For more information, see http://go.microsoft.com/fwlink/?LinkId=153133.



aspx页面.



aspx page.

<%@ Page Language="C#" AutoEventWireup="true" ValidateRequest="false" CodeBehind="Answers.aspx.cs" Inherits="Answers" MasterPageFile="~/AdminDetails.Master"  %>

<asp:Content ID="content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">

    <form id="form1" runat="server">
    <div>
    <asp:GridView ID="grdView" runat="server" AutoGenerateColumns="False" 

            AllowPaging="True" AllowSorting="True" onrowediting="grdView_RowEditing" 

            onrowcancelingedit="grdView_RowCancelingEdit" 

            onrowupdating="grdView_RowUpdating" EnableModelValidation="False">
    <columns>
    <asp:BoundField DataField="ID" HeaderText="Question No" />
    <asp:BoundField DataField="Description" ReadOnly="true" HeaderText="Question" />
    <asp:BoundField DataField="Answer" ReadOnly="true" HeaderText="Answer" />
        <asp:TemplateField HeaderText="Comments">
            <edititemtemplate>
                <%--<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Comments") %>'>--%>
            </edititemtemplate>
            <itemtemplate>
               <%-- <asp:Label ID="Label1" runat="server" Text='<%# Bind("Comments") %>'>--%>
                <asp:TextBox ID="txtComments" runat="server" Text='<%# Bind("Comments") %>'>
            </itemtemplate>
        
        <asp:TemplateField HeaderText="Marks">
            <edititemtemplate>
              <%--  <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("Marks") %>'>--%>
            </edititemtemplate>
            <itemtemplate>
              <%--  <asp:Label ID="Label2" runat="server" Text='<%# Bind("Marks") %>'>--%>
                <asp:TextBox ID="txtMarks" runat="server" Text='<%# Bind("Marks") %>'>
            </itemtemplate>
        
    
    </columns>
      
    
  
    <br />
        <asp:Label ID="lblmessage" runat="server" Text="Message">
        <br />
        <br />
         <asp:Button ID="Button1" runat="server" Height="33px" 

            onclick="Button1_Click" Text="UPDATE" Width="72px" />
        <br />
        <br />
                                                                                                                                                                                            
  
  TotalMarks:<asp:Label ID="lbltotal"  align="right" runat="server">
    </div>
    </form>

推荐答案



错误消息也显然也有解决方法:)

Hi,

The error message clearly has the solution too :)

disable request validation by setting validateRequest="false" in the Page directive or in the <pages> configuration section.



如下所示:



Like below:

<%@ Page Language="C#" AutoEventWireup="true" ValidateRequest = "false"



当您的文本字段中有标签时,通常会发生此错误.
默认情况下,ASP.Net会验证所有输入控件中是否存在潜在不安全的内容,这些内容可能会导致跨站点脚本和SQL注入.因此,它通过抛出上述Exception来禁止此类内容.默认情况下,建议允许在每次回发中进行此检查,但是最好在网格视图中检查是否有任何输入文本,例如``<''或``>''. >
希望这对您有帮助...



This error is mostly occured when there are tags in your text field.
ASP.Net By default validates all input controls for potentially unsafe contents that can lead to Cross Site Scripting and SQL Injections. Thus it disallows such content by throwing the above Exception. By default it is recommended to allow this check to happen on each postback.But its better to check in your grid view, that whether you have any input text like ''<'' or ''>''.

Hope this helps...


将此代码编写为页面索引更改

write this code to page index changing

Gridview1.PageIndex=e.NewPageIndex
BindGrid();


..在这里将代码编写为bindgrid


..here write the code to bindgrid


朋友,

您需要处理pageindexchanging事件.

像下面的代码:

Hi Friend ,

you need to handle the pageindexchanging event.

like below code:

public void gridview_onPageindexchanging(Object Sender,griviewEventArgs e)
{
// you have to handle the above event and set new index
gridview.currentpageindex = e.newpageindex;
BindData();

}


这篇关于分页错误我收到此错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆