Welcome Guest Search | Active Topics | Sign In | Register

ToolBar EnableEventValidation Issue Options
ROI.Solutions
Posted: Friday, August 29, 2008 10:49:26 AM
Rank: Advanced Member
Groups: Member

Joined: 4/22/2008
Posts: 75
Let me explain what happends first on the page. When the user loads the page 2 controls are populated a ToolBar that i use for exporting data and a Grid thats is used to hold the data. On inital load I can expeort the just fine by clicking a button on the tool bar but if i do anything to the grid update, insert, delete, etc.. and then clikc the tool bar i get the following error


Invalid postback or callback argument. Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@ Page EnableEventValidation="true" %> in a page. For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them. If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.


I have heard you can fix it by turning off EventValidation but thats would pose a security risk. I also found people saying you can add

Code: Visual Basic.NET
Page.ClientScript.RegisterForEventValidation(this.UniqueID);


To the Render and it works but your Toolbar doesnt have render on Prender and i get an error saying it can only be added/performed during a render not pre-render.

Any IDeas how to fix this?
eo_support
Posted: Friday, August 29, 2008 11:12:09 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,090
Hi,

In order to call a method in the rendering process, you can override the Render or PreRender on your page or our control and then call it. However the error message itself does indicates a problem, so it would be greatly appreciated if you can produce a test page that demonstrates the error. As soon as we can see the error, it should not be difficult for us to find out the root cause.

Thanks!
ROI.Solutions
Posted: Friday, August 29, 2008 11:20:38 AM
Rank: Advanced Member
Groups: Member

Joined: 4/22/2008
Posts: 75
I tried overriding the Render for the page but still doesnt work. I get the usualy Error Stated above tried serveral triks posted on asp.net Forums. What do you need me to do and it shall be done.
eo_support
Posted: Friday, August 29, 2008 11:25:26 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,090
A sample page would be very helpful. Thanks!
ROI.Solutions
Posted: Friday, August 29, 2008 11:39:30 AM
Rank: Advanced Member
Groups: Member

Joined: 4/22/2008
Posts: 75
Ok sample page Created heres the HTML/ASPX Code


Code: HTML/ASPX
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="Administrators_EMSR_Default" %>

<%@ Register Assembly="obout_Grid_NET" Namespace="Obout.Grid" TagPrefix="obout" %>
<%@ Register Assembly="EO.Web" Namespace="EO.Web" TagPrefix="eo" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>Education Management System Reporting</title>
    <link rel="stylesheet" type="text/css" media="screen" href="Administrators/css/main.aspx" />
    <script language='JavaScript' type="text/javascript">
        function on_item_click(toolBar, toolBarItem)
        {
            var cmd = toolBarItem.getCommandName()
            if (cmd == "Print")
            {
	             reportGrid.print();
	        }
        }
    </script>

    <link display="all" href="Administrators/styles/grid/style_9/style.css" rel="stylesheet"
        type="text/css" />
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <table width="100%">
            <tr>
                <th class="prompt"><asp:Label ID="lblReportTitle" runat="server" Font-Size="Large" Font-Underline="true"></asp:Label></th>
            </tr>
        </table>
        <eo:ToolBar ID="ExportToolBar" runat="server" Width="100%" BackgroundImage="00100203" BackgroundImageLeft="00100201" BackgroundImageRight="00100202" SeparatorImage="00100204" ClientSideOnItemClick="on_item_click" AutoPostBack="True">
            <HoverStyle CssText="BORDER-RIGHT: #335ea8 1px solid; PADDING-RIGHT: 3px; BORDER-TOP: #335ea8 1px solid; PADDING-LEFT: 3px; FONT-SIZE: 12px; PADDING-BOTTOM: 2px; BORDER-LEFT: #335ea8 1px solid; CURSOR: hand; PADDING-TOP: 2px; BORDER-BOTTOM: #335ea8 1px solid; FONT-FAMILY: Tahoma; BACKGROUND-COLOR: #ffe1ac" />
            <ItemTemplates>
                <eo:ToolBarItem Type="Custom">
                    <NormalStyle CssText="background-color:transparent;border-bottom-style:none;border-left-style:none;border-right-style:none;border-top-style:none;padding-bottom:1px;padding-left:2px;padding-right:2px;padding-top:2px;" />
                    <HoverStyle CssText="background-color:transparent;border-bottom-style:none;border-left-style:none;border-right-style:none;border-top-style:none;padding-bottom:1px;padding-left:2px;padding-right:2px;padding-top:2px;" />
                    <DownStyle CssText="background-color:transparent;border-bottom-style:none;border-left-style:none;border-right-style:none;border-top-style:none;padding-bottom:1px;padding-left:2px;padding-right:2px;padding-top:2px;" />
                </eo:ToolBarItem>
                <eo:ToolBarItem Type="DropDownMenu">
                    <NormalStyle CssText="background-image:url('00100205');background-position-x:right;border-bottom-style:none;border-left-style:none;border-right-style:none;border-top-style:none;cursor:hand;padding-bottom:3px;padding-left:4px;padding-right:4px;padding-top:3px;" />
                    <HoverStyle CssText="background-color:#ffe1ac;background-image:url('00100206');background-position-x:right;border-bottom-color:#335ea8;border-bottom-style:solid;border-bottom-width:1px;border-left-color:#335ea8;border-left-style:solid;border-left-width:1px;border-right-color:#335ea8;border-right-style:solid;border-right-width:1px;border-top-color:#335ea8;border-top-style:solid;border-top-width:1px;cursor:hand;padding-bottom:2px;padding-left:3px;padding-right:3px;padding-top:2px;" />
                    <DownStyle CssText="BORDER-RIGHT: #335ea8 1px solid; PADDING-RIGHT: 2px; BORDER-TOP: #335ea8 1px solid; PADDING-LEFT: 4px; BACKGROUND-POSITION-X: right; BACKGROUND-IMAGE: url(00100206); PADDING-BOTTOM: 1px; BORDER-LEFT: #335ea8 1px solid; CURSOR: hand; PADDING-TOP: 3px; BORDER-BOTTOM: #335ea8 1px solid; BACKGROUND-COLOR: #ffe1ac" />
                </eo:ToolBarItem>
            </ItemTemplates>
            <NormalStyle CssText="PADDING-RIGHT: 4px; PADDING-LEFT: 4px; FONT-SIZE: 12px; PADDING-BOTTOM: 3px; CURSOR: hand; BORDER-TOP-STYLE: none; PADDING-TOP: 3px; FONT-FAMILY: Tahoma; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BORDER-BOTTOM-STYLE: none" />
            <Items>
                <eo:ToolBarItem CommandName="MSWord" Text="MS Word">
                </eo:ToolBarItem>
                <eo:ToolBarItem Type="Separator">
                </eo:ToolBarItem>
                <eo:ToolBarItem CommandName="MSExcel"
                    Text="MS Excel">
                </eo:ToolBarItem>
                <eo:ToolBarItem Type="Separator">
                </eo:ToolBarItem>
                <eo:ToolBarItem CommandName="PDF"
                    Text="PDF">
                </eo:ToolBarItem>
                <eo:ToolBarItem Type="Separator">
                </eo:ToolBarItem>
                <eo:ToolBarItem CommandName="Print" 
                    Text="Print">
                </eo:ToolBarItem>
            </Items>
            <DownStyle CssText="BORDER-RIGHT: #335ea8 1px solid; PADDING-RIGHT: 2px; BORDER-TOP: #335ea8 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 12px; PADDING-BOTTOM: 1px; BORDER-LEFT: #335ea8 1px solid; CURSOR: hand; PADDING-TOP: 3px; BORDER-BOTTOM: #335ea8 1px solid; FONT-FAMILY: Tahoma; BACKGROUND-COLOR: #ffe1ac" />
        </eo:ToolBar>
        <div id="divReportGrid">
                    <obout:Grid ID="reportGrid" runat="server" AllowAddingRecords="False" AllowDataAccessOnServer="True" AllowFiltering="True" AllowGrouping="True" AllowManualPaging="True" ExportedFilesTargetWindow="New" HideColumnsWhenGrouping="True" PageSizeOptions="-1,1,2,3,4,5,6,7,8,9,10,50,100,500" ShowGroupsInfo="True" Width="100%">
                    </obout:Grid> 
        </div>
    </div>
    </form>
</body>
</html>
ROI.Solutions
Posted: Friday, August 29, 2008 11:40:48 AM
Rank: Advanced Member
Groups: Member

Joined: 4/22/2008
Posts: 75
HERES the CODE-Behind using the Nothwind database

Code: Visual Basic.NET
Imports System.Data.SqlClient
Imports System.IO

Imports iTEXT = iTextSharp.text
Imports iHTML = iTextSharp.text.html
Imports iPDF = iTextSharp.text.pdf
Partial Class Administrators_EMSR_Default
    Inherits System.Web.UI.Page

#Region "Top Stuff"
    Private oSQLConn As SqlConnection
    Private oSQLCmd As SqlCommand
    Private oReader As SqlDataReader
    Private query As String

    Private menu_ID As String
    Private ueMenu_ID As String
    Private menu_Name As String
    Private rpt_ID As String
    Private ueRPT_ID As String
    Private rpt_Name As String
    Private rpt_Query As String
#End Region

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not IsPostBack Then
            loadReport()
        End If
    End Sub

    Private Sub loadReport()
        query = "SELECT [ProductID], [ProductName], [SupplierID], [CategoryID], [QuantityPerUnit], [UnitPrice], [UnitsInStock], [UnitsOnOrder], [ReorderLevel], [Discontinued], [CategoryName] FROM [Alphabetical list of products]"
        oSQLConn = New SqlConnection("Data Source=ROIOFFICE02;Initial Catalog=Northwind;Integrated Security=True")
        oSQLConn.Open()

        oSQLCmd = New SqlCommand(query, oSQLConn)
        oSQLCmd.CommandType = Data.CommandType.Text

        oReader = oSQLCmd.ExecuteReader()

        reportGrid.DataSource = oReader
        reportGrid.DataBind()

        oReader.Close()
        oSQLConn.Close()
    End Sub

    Private Enum docType
        MSWord
        MSExcel
        PDF
    End Enum

    Protected Sub ExportToolBar_ItemClick(ByVal sender As Object, ByVal e As EO.Web.ToolBarEventArgs) Handles ExportToolBar.ItemClick
        If e.Item.CommandName = "MSWord" Then
            BuildMSDoc(docType.MSWord)
        ElseIf e.Item.CommandName = "MSExcel" Then
            BuildMSDoc(docType.MSExcel)
        ElseIf e.Item.CommandName = "PDF" Then
            BuildPDFDoc(docType.PDF)
        End If
    End Sub

    Private Sub BuildMSDoc(ByVal exportType As docType)
        Dim sExportedGrid As New StringBuilder()
        Dim sFormattingInfo As String = ""

        ' START TABLE
        sExportedGrid.Append("<table border='1'><tr>")

        ' BUILD COLUMNS
        For Each oColumn As Obout.Grid.Column In reportGrid.Columns
            sFormattingInfo = "style='width:" + oColumn.Width + "px;'"
            sFormattingInfo += " align='" + oColumn.HeaderAlign + "'"
            sExportedGrid.Append("<td " + sFormattingInfo + "><b>" + oColumn.HeaderText + "</b></td>")
        Next
        sExportedGrid.Append("</tr>")

        ' BUILD ROWS
        For Each oRow As Obout.Grid.GridRow In reportGrid.Rows
            Dim currentRow As Hashtable = oRow.ToHashtable()
            sExportedGrid.Append("<tr>")

            For Each oColumn As Obout.Grid.Column In reportGrid.Columns
                sFormattingInfo = ""
                sFormattingInfo = "style='width:" + oColumn.Width + "px;'"
                sFormattingInfo += " align='" + oColumn.Align + "'"

                If Not currentRow(oColumn.DataField) = Nothing Then
                    sExportedGrid.Append("<td " + sFormattingInfo + ">" + System.Web.HttpUtility.HtmlEncode(currentRow(oColumn.DataField).ToString()) + "</td>")
                Else
                    sExportedGrid.Append("<td " + sFormattingInfo + ">" + System.Web.HttpUtility.HtmlEncode("...") + "</td>")
                End If
            Next
            sExportedGrid.Append("</tr>")
        Next

        ' END TABLE
        sExportedGrid.Append("</table>")
        ExportToBrowser(exportType, sExportedGrid)
    End Sub

    Private Sub BuildPDFDoc(ByVal exportType As docType)
        Dim pTable As New iPDF.PdfPTable(reportGrid.Columns.Count)

        Dim arWD As New ArrayList()
        For Each oColumn As Obout.Grid.Column In reportGrid.Columns
            Dim pCell As New iPDF.PdfPCell(New iTEXT.Phrase(0, oColumn.HeaderText.ToString()))
            pCell.BackgroundColor = iTEXT.Color.GREEN
            pCell.NoWrap = False
            pTable.AddCell(pCell)
        Next

        ' BUILD ROWS
        For Each oRow As Obout.Grid.GridRow In reportGrid.Rows
            Dim currentRow As Hashtable = oRow.ToHashtable()

            For Each oColumn As Obout.Grid.Column In reportGrid.Columns
                Dim pCell As New iPDF.PdfPCell(New iTEXT.Phrase(0, currentRow(oColumn.DataField).ToString()))
                pCell.BackgroundColor = iTEXT.Color.ORANGE
                pCell.NoWrap = False
                pTable.AddCell(pCell)
            Next
        Next


        Dim ms As New MemoryStream
        Dim document As New iTEXT.Document(iTEXT.PageSize.A4.Rotate())
        'Dim document As New iTEXT.Document(iTEXT.PageSize.A4)
        document.SetMargins(0, 0, 50, 50)
        Try
            Response.ContentType = "application/pdf"
            iPDF.PdfWriter.GetInstance(document, ms)

            document.Open()
            document.Add(pTable)
            document.Close()

            'document.Open()
            'Dim xmlReader As New System.Xml.XmlTextReader(New StringReader(strHTMLContent.ToString()))
            'iHTML.HtmlParser.Parse(document, xmlReader)
            'document.Close()
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try

        Response.OutputStream.Write(ms.GetBuffer(), 0, ms.GetBuffer().Length)
        Response.OutputStream.Flush()
        Response.OutputStream.Close()
    End Sub

    Private Sub ExportToBrowser(ByVal exportType As docType, ByVal TableString As StringBuilder)
        HttpContext.Current.Response.Clear()
        HttpContext.Current.Response.Charset = ""

        Dim sFilename As String = ""
        Dim sTimeStamp As String = DateTime.Now.Month.ToString() + "." + DateTime.Now.Day.ToString() + "." + DateTime.Now.Year.ToString()
        sTimeStamp += "_" + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString()

        If exportType = docType.MSWord Then
            HttpContext.Current.Response.ContentType = "application/msword"
            sFilename = lblReportTitle.Text + "_(" + sTimeStamp + ").doc"
        ElseIf exportType = docType.MSExcel Then
            HttpContext.Current.Response.ContentType = "application/msexcel"
            sFilename = lblReportTitle.Text + "_(" + sTimeStamp + ").xls"
        End If

        HttpContext.Current.Response.AddHeader("Content-Disposition", "inline;filename=" + sFilename)
        HttpContext.Current.Response.Write(TableString.ToString())
        HttpContext.Current.Response.End()
        HttpContext.Current.Response.Flush()
    End Sub
End Class
eo_support
Posted: Friday, August 29, 2008 11:45:35 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,090
Hi,

We won't really be able to run your page when it relies on your database. Is it possible for you to construct some test data by code instead of getting them from your database?

We won't be able to do anything with iTextSharp either. So we would need a sample that does not include that. Since you are only using it to generate a separate page, in theory it should not cause the validation error that you are seeing.

Thanks
ROI.Solutions
Posted: Friday, August 29, 2008 1:04:02 PM
Rank: Advanced Member
Groups: Member

Joined: 4/22/2008
Posts: 75
You guys dont have the Default MS DataBase NorthWind that comes with SQL Server?
ROI.Solutions
Posted: Friday, August 29, 2008 1:05:57 PM
Rank: Advanced Member
Groups: Member

Joined: 4/22/2008
Posts: 75
This also isnt going to work because im using a GRID that is not yours NOR MS. Is there a way you can do a web session and i can show you the issue?
ROI.Solutions
Posted: Friday, August 29, 2008 1:33:19 PM
Rank: Advanced Member
Groups: Member

Joined: 4/22/2008
Posts: 75
FINALLY, I FOUND THE CAUSE.

The error i was getting didnt give much detail but after 4 days of search i found the isseu and this is and issue with ANY CONTROL THAT IS CREATED VIA A DATABIND OR PROGRAMATICALLY ADDED TO THE PAGE. The must be unique IDs for each item. What was happening with my was the grid i use build essentiall a table string of <tr>'s and <td>'s and i can select a option to display so many <tr>'s on a given page from like 1,2,3.. to ALL well when doing this i got the error because each TR didnt have a unique ID. Luckily my grid has a feature for turning on Unique ID Gernerator Automatically.
eo_support
Posted: Friday, August 29, 2008 2:06:11 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,090
Hi,

Glad to hear that you found out the cause....however we are not quite following your explanation. We could do a web session if you still want us to; But if you suspect this to be a problem with our product, then a web session won't work because we won't be able to debug against our source code on your machine. Just feel free to let us know if you still need any help.

Thanks!
ROI.Solutions
Posted: Friday, August 29, 2008 2:27:26 PM
Rank: Advanced Member
Groups: Member

Joined: 4/22/2008
Posts: 75
Not really an issue with your product i guess its more how MS build the EnabeldEventValidation Module for .Net 2.0 i can show you what i did to reolve it but it is resolved.


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.