Monday, March 26, 2012

Deriving custom control from UpdatePanel doesnt work

I previously created multiple controls by deriving them from UpdatePanel using ATLAS (before BETA). Today I tried switching one of the controls to BETA and now I am getting PageRequestManagerParserErrorException error.

I created a very simple control to reproduce the problem:

===================================

namespace AtlasControls
{
[ToolboxData("<{0}:TestAtlasCtrl runat=server></{0}:TestAtlasCtrl>")]

public class TestAtlasCtrl : UpdatePanel, INamingContainer
{

public TestAtlasCtrl()
{
}


protected override void Render(HtmlTextWriter writer)
{
writer.WriteLine("Custom text is here...");
base.Render(writer);
}
}
}

=========================================

Here is the test page where I use the control:

==========================================

<%@dotnet.itags.org. Page Language="C#" AutoEventWireup="true" CodeFile="Test.aspx.cs" Inherits="AtlasBeta_Test" %>
<%@dotnet.itags.org. Register TagPrefix="Custom" Namespace="AtlasControls" %
<!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 runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<atlas:ScriptManager runat="server" ID="scriptManager" />
<div>
<Custom:TestAtlasCtrl ID="dlgForgotPassword" runat="server">
<ContentTemplate>
<asp:panel ID="panelForgotPasswordForm" runat="server">
<asp:TextBox id="txtEmail" Columns="40" MaxLength="255" CssClass="xTextBox" runat="server"/>
<asp:RequiredFieldValidator ID="vtxtEmail" ControlToValidate="txtEmail" EnableClientScript="false" runat="server" ErrorMessage="Email is required"></asp:RequiredFieldValidator>
<br /><br />

<center>
<asp:Button ID="btnOk" runat="server" CssClass="xSubmitPrimary" Text="OK" OnClick="btnOk_Click"></asp:Button>
</center>
</asp:panel>
</ContentTemplate>
</Custom:TestAtlasCtrl>
</div>
</form>
</body>
</html>
===================================

When I click OK in the form without entering 'Email' I get PageRequestManagerParserErrorException error. The error hints that it can be caused by Response.Write() and overriding HttpHandlers, but I am not doing any of that.

Regards,

Eric Popivker

I tested your codes and found the same issue as you said in your post.The issue is in the code line "writer.WriteLine("Custom text is here...");".In Ajax controls,you can not use the functionality which is similar toResponse.Writebecause there is no postback happening if you don't specify triggers.
Wish this can help u.

No comments:

Post a Comment