You are currently viewing the BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
Tried creating my very first AJAX ASP.NET usercontrol and hook it into the existing site today. I started off with (what I thought was) a real simple control. So I created a new user control (after having added all kinds of weird stuff to my web.config in order to configure Ajax), dragged a ScriptManager, an UpdatePanel, and a timer onto it, followed by a label.
I set the timerinterval to 1000 (1 second. I know this creates additional bandwith. However, for now that's fine with me), and in the codebehind on the Tick event of the timer, I update the label to reflect the current UTC time.
Easy peasy.I'm feeling like the MacDaddy of the AJAX already.
Shock, horror though when I registered the event on my page, put it where I want it (which happens to be a container), and then run the site.Nasty evil errormessages! Curse them!
"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 done some reading up, and I'm quite sure what happens. I also understand why it happens, and the reasoning behind wanting validation for postbacks. I tried using the following snippet of code, posted inside my usercontrol:
protected override void Render(System.Web.UI.HtmlTextWriter writer)
However, then my page loads, but no control. Nada. I also tried the OnInit event, but that doesn't help either. enableEventValidation=true is just not an option as far as I'm concerned.
Can anyone tell me what I might be doing wrong, please? It's such a simple control, I must be overlooking something :(
I tried setting the enableEventValidation in the master page, but no result. I also have this question on the asp.net forums, but have been unable to get help there so far.
I'd love to be able to write a bunch of AJAX user controls I can then hook up as WebParts, but hopefully without this much hassle :(
I spent some time today browsing other threads on asp.net, and tried out a bunch of ideas from there.
The one suggestion that made the difference was someone suggesting to look for <form> tags.
Sure enough, within my masterpage, I had a form tag, and within that, a paypal donate button.
I played around with things a little, and by moving the paypal button outside the original formtag, I now am able to get things working, without requiring any nasty prerender or registerforeventsalidation crap.
However, I ran into a different problem now. After about 10 minutes of leaving my page open, I was getting pop-ups complaining about something (don't exactly recall the message, and I'm at work now). I traced the error back to what seems to be an auto-logoff happening after some time.
In my code, I had added a Response.Redirect to Default by implementing an event in the LoginStatus control. I changed that to use an internal option of the control (LogoutPageUrl), but receive the error again.
My guess is that TBH has a setting somewhere regardng a Session timing out. I did a quick search on Session in the code, but came up blank. Does anyone remember anything about this, and where it was set?
(I also ran into some Session trouble with your logout tip, Jim. For now, I have disabled it, but I'd really like to see that fucntionality back in my website again).
My guess is that the session timing out is somehow interfering with the AJAX postbacks, and I'd love to bite into it, but have no idea where to start :)
I have a temporary site up at www.entropiaonline.com, which is running at the provider. I do most of my testing with local pages, running against the database at the provider.
However, in both situations, the error comes up.
The error I got yesterday was something to do with Sys.Webforms.PageRequestmanagerparsererrorexceptio n. I tried a few things, but so far to no avail.
For the moment, I've decided just to remove my control again. I have already spent too much time on the issue, and frankly, the site should have been up and in beta test last weekend. I'll try and finish up two other things I wanted to implement, then get my beta peeps in, and in the meantime, I might try and work on the AJAX errors.
I'd really want to solve the AJAX errors, though, as they'd allow me to add some cool content the users will love. So here's keeping my fingers crossed for finding an easy solution :)
One thing I did notice. I noticed the error spawning far far faster on a few pages. I haven't really put my finger on it yet, nor have I done extensive testing, but it seems as if the FCKControl might be the common factor. I'll have to look into that more before jumping to conclusions though.
Peter, one thing to check on compilation of your 'remote' site is that you have the <compilation debug="false"> in web.config set to false, this makes a HUGE difference to loading and performance. i'm sure you knew this but just in case!!