UpdatePanel Question

  • Thread starter Thread starter Scooby Dog
  • Start date Start date
S

Scooby Dog

Could someone help. I have a form with a grid in one updatepanel 'updGrid',
mode=Conditional, and a detail panel 'updDetail', also in an UpdatePanel
mode=Conditional) that toggles visible when a commandfield in the grid is
clicked. The problem I'm having is if you click the button 'updDetail'
twice and the detail panel is visible I get a the following error.

***************Error**************
Microsoft JScript runtime error:
Sys.WebForms.PageRequestManagerServerErrorException: 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.
*********************************

What really has me confused is it doesn't matter if the button
="btnPrintDetail" is inside or outside the 'updDetail' the error still
occurs if the detail panel is visible.




<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="maincontent"
runat="Server">
<div id="adminedit">
<div class="formsection">
Wausau Steel Purchasing Inquiry
</div>
<br />
<div id="search">
Search Inquirys:<br />
<asp:UpdatePanel ID="updSearch" runat="server">
<ContentTemplate>
<asp:TextBox ID="txtSearch" runat="server"
Width="80px"></asp:TextBox>
<span style="width: 100px">&nbsp;</span>
<asp:Button ID="btnSearch" runat="server" Text="Search"
/>
<span style="width: 100px">&nbsp;</span>
<asp:Button ID="btnClear" runat="server" Text="Clear" />
</ContentTemplate>
</asp:UpdatePanel>
</div>
<br />
<!-- I remved id="projectadministration" from this div -->
<div id="MainGrid">
<a name="content_start" id="content_start"></a>
<fieldset>
<!-- add H2 here and hide it with css since you can not put
h2 inside a legend tag -->
<h2 class="none">
Inquiry Status</h2>
<legend>Active Inquirys:</legend>

<asp:UpdatePanel ID="updGrid" runat="server"
UpdateMode="Conditional">
<ContentTemplate>
<asp:GridView ID="gvInqStatus"
AutoGenerateColumns="False" DataKeyNames="inqID" AllowSorting="True"
BorderWidth="0" runat="server"
BorderStyle="None" Width="90%" CellPadding="2"
AllowPaging="true" PageSize="10"
BorderColor="White">
<Columns>
<asp:BoundField DataField="inqID"
HeaderText="Inquiry Number" SortExpression="InqID"
Visible="true" />
<asp:BoundField DataField="CustNum"
HeaderText="Customer Number" SortExpression="CustNum" />
<asp:BoundField DataField="DistrictCode"
HeaderText="District" SortExpression="DistrictCode" />
<asp:BoundField DataField="SalesNum"
HeaderText="Sales Number" SortExpression="SalesNum" />
<asp:BoundField DataField="Description"
HeaderText="Description" SortExpression="Description" />
<asp:BoundField DataField="CustPO"
HeaderText="Customer PO" SortExpression="CustPO" />
<asp:BoundField DataField="QuoteDate"
HeaderText="Quote Date" DataFormatString="{0:d}"
SortExpression="QuoteDate" />
<asp:BoundField DataField="Status"
HeaderText="Quote Status" SortExpression="Status" />
<asp:CommandField ShowSelectButton="true"
HeaderText="View Detail" SelectImageUrl="App_Themes/images/grid-view.gif"
ButtonType="Image" SelectText="View" />
</Columns>
<RowStyle HorizontalAlign="Left" CssClass="row1"
/>
<HeaderStyle CssClass="grid-header"
HorizontalAlign="Left" />
<EmptyDataTemplate>
<asp:Label ID="Label10" runat="server"
Text="Label">There are no Purchase Inquirys Entered</asp:Label>
</EmptyDataTemplate>
</asp:GridView>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnSearch"
EventName="click" />
<asp:AsyncPostBackTrigger ControlID="btnClear"
EventName="click" />
</Triggers>
</asp:UpdatePanel>
</fieldset>
</div>

<div id="inqDetails">
<asp:UpdatePanel ID="updDetail" runat="server"
UpdateMode="Conditional">
<ContentTemplate>
<asp:Panel ID="pnlView" runat="server">
<fieldset>
<legend>Inquiry Details: </legend>


***** I removed a table to shorten
this sample code.*****

<asp:UpdatePanel ID="updPrintDetail"
runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Button ID="btnPrintDetail"
runat="server" Text="Print" style="float: right;" />
</ContentTemplate>
</asp:UpdatePanel>
</div>
</fieldset>
</asp:Panel>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="gvInqStatus"
EventName="SelectedIndexChanged" />
<asp:AsyncPostBackTrigger ControlID="btnSearch"
EventName="Click" />
<asp:AsyncPostBackTrigger ControlID="btnClear"
EventName="Click" />
</Triggers>
</asp:UpdatePanel>
</div>
<asp:HiddenField ID="TransID" runat="server" />
</div>
</asp:Content>
 
I just wanted to add that I have taken the button "btnPrintDetail"out of the
UpdatePanel "updPrintDetail" and added code to the btnPrintDetail.Click
event to redisplay the panel ie: pnlView.visible = true, and the problem

went away. I Could someone elaborate on what could actually be causing

this, I just want to understand why my fix actually works?





Dave.
 
Back
Top