473,785 Members | 2,784 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Invalid postback or callback argument is driving me nuts!

Hi all experts,

I am going nuts with this Invalid postback or callback argument thingy
with .Net 2.0

I am building a file attachment module which relays on a Datatable
stored in session (yeah i know its unhealthy, but its the only "clean"
approach which I can think of to avoid tranfering temp files onto the
server) to maintain the list of attached files before the "commit"
action is done to transfer all the files onto the server.

I have a function which allows the user to delete the attached file
before the "commit" action is performed. Essentially, the "delete" is
deleting a row from the Datatable stored in session. When I was doing
testing of this code in the early phase, all works well, but suddenly a
few days later, when I improved the codes to incorporate other
functions, whenever I click on the "delete" button (which is a template
column with an image button that triggers a "RowCommand " to handle the
deletion) i will hit the Invalid postback error. I have since removed
those new codes but I am still stuck with the problem.

Someone help me please! I am totally clueless as how to resolve this
issue. I have tried to turn off the EnableEventVali dation at the page
level, but when I do so, my "RowCommand " event is not being triggered
(it works fine if i turn on the validation). You guys see the
fustration I am facing here?

Would really really be glad if someone could help me. I have attached
my codes below so you guys can help me take a look. Do let me know if
you need more information.

------------- Code Behind ---------------

Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArg s) Handles Me.Load
If Not IsPostBack Then
BindAttachmentG rid(True)
Else
BindAttachmentG rid(False)
End If
vldInvalidFile. Visible = False
vldLimitExceede d.Visible = False
vldDuplicate.Vi sible = False
End Sub

Private Sub BindAttachmentG rid(ByVal blnBindEmpty As Boolean)
Dim dt As DataTable
If blnBindEmpty = False Then
dt = Me.p_Attachment TempStorage <-- "this
p_AttachmentTem pStorage is a private property which will determine if
an existing DT is stored in the session, if not, it will call the
CreateAttachmen tDT" -->
End If
gdvAttachment.D ataSource = dt
gdvAttachment.D ataBind()
End Sub

Private Sub CreateAttachmen tDT()
Dim dtAttach As New DataTable
dtAttach.Column s.Add("ID", GetType(Integer ))
dtAttach.Column s.Add("FileName ", GetType(String) )
dtAttach.Column s.Add("RawFileS ize", GetType(Integer ))
dtAttach.Column s.Add("FileSize ", GetType(String) )
dtAttach.Column s.Add("Uploaded By", GetType(String) )
dtAttach.Column s.Add("Uploaded DateTime", GetType(String) )
dtAttach.Column s.Add("FileStre am",
GetType(WebCont rols.FileUpload ))
dtAttach.Column s.Add("FileType Flag", GetType(String) )
dtAttach.Column s.Add("FilePath ", GetType(String) )
dtAttach.Primar yKey = New DataColumn() {dtAttach.Colum ns("ID")}
Me.p_Attachment TempStorage = dtAttach
End Sub

Protected Sub btnAttach_Click (ByVal sender As Object, ByVal e As
System.EventArg s) Handles btnAttach.Click
If fileAttach.HasF ile = True Then
Dim tmpTotalSize As Double = Me.p_TotalUploa dedSize <--
"all Me.p_XXXX are simply private property which stores information in
viewstate" -->
tmpTotalSize += fileAttach.Post edFile.ContentL ength
If tmpTotalSize 10485760 Then
vldLimitExceede d.Visible = True
Exit Sub
End If
If Me.p_AllowDupli cation = False Then
For Each dRowItem As DataRow In
Me.p_Attachment TempStorage.Row s
If dRowItem("FileN ame").ToString. Trim =
fileAttach.File Name Then
vldDuplicate.Vi sible = True
Exit Sub
End If
Next
End If
Dim dRow As DataRow
Me.p_TotalUploa dedSize +=
fileAttach.Post edFile.ContentL ength
dRow = Me.p_Attachment TempStorage.New Row()
Me.p_Attachment ID += 1
dRow("ID") = Me.p_Attachment ID
dRow("FileName" ) = fileAttach.File Name
dRow("RawFileSi ze") = fileAttach.Post edFile.ContentL ength
dRow("FileSize" ) =
ConvertFileSize (fileAttach.Pos tedFile.Content Length)
dRow("UploadedB y") =
clsUser.getUser Name(clsUser.ge tEmployeeIDByLo ginID(MyBase.Ge tLogonUser()))
dRow("UploadedD ateTime") = Format(Now,
clsUtil.ConfigV alue("dateTimeF ormat"))
dRow("FileStrea m") = fileAttach
dRow("FileTypeF lag") = "New"
dRow("FilePath" ) = ""
Me.p_Attachment TempStorage.Row s.Add(dRow)
Me.p_Attachment TempStorage.Acc eptChanges()
If gdvAttachment.P ageCount <0 Then
gdvAttachment.P ageIndex = gdvAttachment.P ageCount
End If
BindAttachmentG rid(False)
Else
vldInvalidFile. Visible = True
End If

End Sub

Protected Sub gdvAttachment_R owDataBound(ByV al sender As Object,
ByVal e As System.Web.UI.W ebControls.Grid ViewRowEventArg s) Handles
gdvAttachment.R owDataBound
If e.Row.RowType = DataControlRowT ype.Header Then
e.Row.Cells(2). Text = "Size <br>(" &
ConvertFileSize (Me.p_TotalUplo adedSize) & " Total)"
ElseIf e.Row.RowType = DataControlRowT ype.DataRow Then
Dim lBtnFileName As LinkButton =
CType(e.Row.Fin dControl("lBtnF ileName"), LinkButton)
lBtnFileName.Co mmandArgument = e.Row.DataItem( "ID")
AddHandler lBtnFileName.Cl ick, AddressOf lBtnFileName_Cl ick
CType(e.Row.Fin dControl("btnAt tachmentDelete" ),
ImageButton).At tributes.Add("o nclick", "return confirm('Are you sure
you want to delete " & e.Row.DataItem( "FileName") & "?')")
CType(e.Row.Fin dControl("btnAt tachmentDelete" ),
ImageButton).Co mmandArgument = e.Row.DataItem( "ID")
End If
End Sub

<-- "The following code suppose to be the one to handle the delete
event, but before this code is even run, I hit the above error
already!" -->
Protected Sub gdvAttachment_R owCommand(ByVal sender As Object,
ByVal e As System.Web.UI.W ebControls.Grid ViewCommandEven tArgs) Handles
gdvAttachment.R owCommand
If e.CommandName = "CustomDele te" Then
Try
Dim dRow As DataRow =
Me.p_Attachment TempStorage.Row s.Find(e.Comman dArgument)
If dRow("FileTypeF lag") = "Existing" Then
If System.IO.File. Exists(dRow("Fi lePath")) = True
Then
System.IO.File. Delete(dRow("Fi lePath"))
End If
End If
Me.p_TotalUploa dedSize -= dRow("RawFileSi ze")
Me.p_Attachment TempStorage.Row s.Remove(dRow)
BindAttachmentG rid(False)
Catch ex As Exception
Throw New Exception(ex.Me ssage)
End Try
End If
End Sub

By the way, the above codes are in a UserControl and the control is
place inside a plain aspx page.

Regards,
Jason

Nov 2 '06 #1
5 6862
Hello all.

Upon further research, I found my error was caused by the "Delete"
image button which resides in the template column of my gridview.

If i use a standard command button it works. But I need to use the
image button of coporate standard requirement!

Anyone have any idea how can i resolve this image button with grid view
problem?

I search the groups and found another thread start whom encounter the
same problem as me, including the fact when we disable the
"EnableEventVal idation" function, the event for the RowCommand is not
triggering. Regretfully no one answered him.

Any idea anyone?

Nov 2 '06 #2
i have the same problem...
some news ???

jason wrote:
Hello all.

Upon further research, I found my error was caused by the "Delete"
image button which resides in the template column of my gridview.

If i use a standard command button it works. But I need to use the
image button of coporate standard requirement!

Anyone have any idea how can i resolve this image button with grid view
problem?

I search the groups and found another thread start whom encounter the
same problem as me, including the fact when we disable the
"EnableEventVal idation" function, the event for the RowCommand is not
triggering. Regretfully no one answered him.

Any idea anyone?
Nov 3 '06 #3
hello any help anyone?

Nov 4 '06 #4
Just had the same problem. Found that I shouldn't do a DataBind() on
the LoadEvent. More details on my Blog (Shameless plug):
http://droyad.blogspot.com/2006/12/i...-argument.html

jason wrote:
hello any help anyone?
Dec 14 '06 #5
Just had the same problem. Found that I shouldn't do a DataBind() on
the LoadEvent. More details on my Blog (Shameless plug):
http://droyad.blogspot.com/2006/12/i...-argument.html

merco wrote:
i have the same problem...
some news ???

jason wrote:
Hello all.

Upon further research, I found my error was caused by the "Delete"
image button which resides in the template column of my gridview.

If i use a standard command button it works. But I need to use the
image button of coporate standard requirement!

Anyone have any idea how can i resolve this image button with grid view
problem?

I search the groups and found another thread start whom encounter the
same problem as me, including the fact when we disable the
"EnableEventVal idation" function, the event for the RowCommand is not
triggering. Regretfully no one answered him.

Any idea anyone?
Dec 14 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2455
by: JULO | last post by:
Hi, I have this problem: In GridView I have template column with ImageButtons - for deleting row. When I click on that button I get this message 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...
2
13231
by: Ray Stevens | last post by:
Anyone see this error that appears to have cropped up with the RTM version of .NET: BASE EXCEPTION:: System.ArgumentException: 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...
1
17048
by: Timbo | last post by:
Hi all, This is my first message here so i'll try and include all the information that will help you help me out, if possible. Basically I am using C# in ASP.NET 2.0 and have a Repeater control in my aspx page with two image buttons, one for an edit command, another a delete command. Here is a cut down code fragment. ...
3
7426
by: Martin | last post by:
Hi, I have an aspx page with two dropdownlist controls. I update the options in the second ddl based on selection made in the first. I do this with the ICallbackEventHandler interface, as per "Implementing Client Callbacks Without Postbacks in ASP.NET Web Pages" (http://msdn2.microsoft.com/en-us/library/ms178208.aspx) This works.
2
620
by: Wizzard | last post by:
I have a repeater with and imagebutton on a page useing VS2005 ASP.Net 2.0 <asp:Repeater ID="Repeater1" runat="server" > <ItemTemplate> <div> <asp:ImageButton ImageUrl="button.gif" ID="ImageButton1" runat="server" /> <p><%# Eval("Name") %></p> </div> </ItemTemplate>
3
8707
by: Nathan Sokalski | last post by:
I am recieving the following error on the second postback of a page I have written: The state information is invalid for this page and might be corrupted Stack Trace: System.Convert.FromBase64String(String s) +0
2
2177
by: Nathan Sokalski | last post by:
I have a DataList in which the ItemTemplate contains two Button controls that use EventBubbling. When I click either of them I receive the following error: Server Error in '/' Application. -------------------------------------------------------------------------------- Invalid postback or callback argument. Event validation is enabled using <pages enableEventValidation="true"/in configuration or <%@ Page EnableEventValidation="true"...
9
4565
by: 200dogz | last post by:
Hi guys, I want to have a button which opens up a new window when pressed. <asp:Button ID="Button1" runat="server" Text="Open new window" /> ... Button1.Attributes.Add("OnClick",
0
9645
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10329
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10152
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9950
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8974
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6740
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5381
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4053
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.