Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > UpdatePanel and UserControl.

Reply
Thread Tools

UpdatePanel and UserControl.

 
 
Tino Donderwinkel
Guest
Posts: n/a
 
      04-09-2010
Hi,

I have create two simple UserControls that use UpdatePanels internally.
These UserControls are used on a 'main' page.

Both UserControls reside in a seperate UpdatePanel on the 'main' page. These
UpdatePanels hold logic for 'updating' the UserControls;

<asp:UpdatePanel ID="updatePanel1" runat="server" ChildrenAsTriggers="False"
UpdateMode="Conditional" EnableViewState="False">
<ContentTemplate>
<asp:TextBox ID="textBox1" Text="something"
runat="server"></asp:TextBox>
<asp:Button ID="button1" runat="server" Text="Load..."
CausesValidation="false" onclick="button1_Click" />
<uc1:UserControl ID="uc1" runat="server" EnableViewState="false" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="button1" EventName="Click" />
</Triggers>
</asp:UpdatePanel>

The code behind the button1_Click event is;

protected void button1_Click(object sender, EventArgs e)
{
uc1.Property = textBox1.Text;
uc1.Update();
}

Now, all UserControls work perfectly well independently. The UpdatePanel on
the 'main' page makes sure only the UserControl I want to update is updated.

But if I put two different UserControls in seperate UpdatePanels on the
'main' page, buttons inside the UserControls throw the dreaded
Sys.WebForms.PageRequestManagerServerErrorExceptio n exception when the
postback of UpdatePanel of the OTHER UserControl is triggered after the last
postback of the UpdatePanel I clicked the button in. (Still with me?)

To clarify; This Exception ONLY occurs if I do this (or vice versa):

Click 'button1' to 'update' the first UpdatePanel that has UserControl1.
(Now here, I can do anything I want to UserControl1; all buttons (triggers)
can be clicked, and the UserControl1 refreshes perfectly. It behaves as
expected.)

Click 'button2' to 'update' the second UpdatePanel that has UserControl2.
(Now here, I can do anything I want to UserControl2; all buttons (triggers)
can be clicked, and the UserControl2 refreshes perfectly. It behaves as
expected.)

If I click 'button1' again to update the first UpdatePanel that has
UserControl1, the control is 'updated' and can be used as expected. (great)

Now for the problem;

If I Click on a trigger button in UserControl2, the dreaded exception is
raised;

Microsoft JScript runtime error:
Sys.WebForms.PageRequestManagerServerErrorExceptio n: 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.

So if I do anything that triggers a postback of a UserControl that is NOT
the UserControl that was last 'updated' by one of the buttons/UpdatePanels
on the 'main' page, the error occurs.

The UserControls have been designed in such a way that they do not rely on
ViewState. (There is only one important property, and that is held in
ControlState.)

I'm using Visual Studio 2010 RC1 with the .NET Framework 4.0 RC.

The ScriptManager I'm using on the 'main' Page is the AJAX Toolkit
ScriptManager and is compiled from the latest build against .NET 4.0.

So what's causing this and how can I resolve this issue? (And please don't
say I have to disable EventValidation...)

Thanks,

Tino

 
Reply With Quote
 
 
 
 
Kobus van Jaarsveldt
Guest
Posts: n/a
 
      08-31-2010
Hi Tino,

I ran into a similar problem.

The following link explains the problem & remedy in detail.

http://couldbedone.blogspot.com/2007...panel-and-even
t.html

I hope it works for you.

Regards
Kobus van Jaarsveldt

*** Sent via Developersdex http://www.developersdex.com ***
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Triggering an UpdatePanel with a trigger located outside of the UpdatePanel Nathan Sokalski ASP .Net 1 06-15-2009 06:23 PM
refresh an updatePanel in an other updatePanel fran_j_diaz@yahoo.fr ASP .Net 3 08-08-2007 06:30 AM
Custom UpdatePanel - ASP.NET 2.0 and Client Callback ThunderMusic ASP .Net 3 11-29-2006 06:10 PM
updatepanel and javascript =?Utf-8?B?cm9kY2hhcg==?= ASP .Net 0 10-25-2006 08:47 PM
Master Pages and Ajax UpdatePanel =?Utf-8?B?cm9kY2hhcg==?= ASP .Net 0 10-06-2006 09:10 PM



Advertisments