Tags: __dopostback, ajax, aspnet, control, defined, error, inside, net, postback, step, step2, updatepanel, wizard, wizardcontrol

"__doPostBack is not defined" error with WizardControl in Updatepanel

On .Net » ASP.NET AJAX

7,817 words with 1 Comments; publish: Sat, 05 Jan 2008 20:23:00 GMT; (10078.13, « »)

When using a wizardControl inside an updatepanel, if the first wizard step does not have a control that does a postback, then when u goto step2 and a control needs to do a postback, it gives the error "__doPostBack is not defined". this can be reproduced by creating a page with the following code:

<%.net-ajax.itags.org. Page Language="C#" AutoEventWireup="true" CodeFile="bug2.aspx.cs" Inherits="bug2" %

<!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">

<div>

<atlas:ScriptManager ID="ScriptManager1" EnablePartialRendering="true" runat="server" >

</atlas:ScriptManager>

<atlas:UpdatePanel ID="panel" runat="server">

<ContentTemplate>

<div style="width:100%; ">

<div class="Wizard">

<asp:Wizard FinishDestinationPageUrl="~/Finish.aspx" Width="100%" ID="wizRS" runat="server" ActiveStepIndex="0" DisplayCancelButton="True" HeaderText="Report Scheduler Wizard" DisplaySideBar="False" CancelButtonText="Reset" FinishCompleteButtonText="Finish">

<WizardSteps>

<asp:WizardStep ID="step1" runat="server" Title="Step 1 (Select Report)">

<table width="100%">

<tr>

<td colspan="2">Report:<asp:CompareValidator ID="valDropReport" runat="server" ValidationGroup="step1"

ErrorMessage="Select a Report" Text="*" ValueToCompare="-1" Operator="GreaterThan" Type="Integer" EnableClientScript="false" ControlToValidate="dropReport"></asp:CompareValidator>

<br />

<asp:DropDownList ID="dropReport" ValidationGroup="step1" DataSourceID="reportODS" DataTextField="ReportName" DataValueField="ReportID" runat="server">

</asp:DropDownList>

<asp:ObjectDataSource ID="reportODS" runat="server" OldValuesParameterFormatString="original_{0}"

SelectMethod="Select" TypeName="Storm.Atlas.Logic.Report.ReportODS"></asp:ObjectDataSource>

</td>

</tr>

<tr>

<td colspan="2">

<asp:ValidationSummary ID="valSummaryStep1" ValidationGroup="step1" runat="server" DisplayMode="List" CssClass="Errors" />

</td>

</tr>

</table>

</asp:WizardStep>

<asp:WizardStep ID="step2" runat="server" Title="Step 2 (Schedule)">

<table width="100%">

<tr>

<td>

Schedule Type:<asp:CustomValidator EnableClientScript="false" ValidationGroup="step2" ID="valType" Text="*" runat="server" ErrorMessage="Select a Schedule Type"></asp:CustomValidator>

</td>

<td>

<asp:RadioButtonList CausesValidation="false" CssClass="Radio" ID="rdbRecurring" runat="server" RepeatDirection="Horizontal" AutoPostBack="True">

<asp:ListItem Selected="true" Value="0">Once-Off</asp:ListItem>

<asp:ListItem Value="1">Daily</asp:ListItem>

<asp:ListItem Value="2">Weekly</asp:ListItem>

<asp:ListItem Value="3">Monthly</asp:ListItem>

</asp:RadioButtonList>

</td>

</tr>

<tr>

<td colspan="2">

<asp:ValidationSummary ValidationGroup="step2" ID="valSummaryStep2" runat="server" CssClass="Errors" />

</td>

</tr>

</table>

</asp:WizardStep>

<asp:WizardStep ID="step3" runat="server" Title="Step 3 (Report Paramaters)">

</asp:WizardStep>

</WizardSteps>

<StepStyle CssClass="WizStep" />

<SideBarStyle CssClass="WizSidebar" HorizontalAlign="Center" VerticalAlign="Bottom" />

<NavigationStyle CssClass="WizNav" />

<HeaderStyle CssClass="WizHeader" />

<StepNavigationTemplate>

<asp:Button ID="StepPreviousButton" runat="server" CausesValidation="False" CommandName="MovePrevious"

Text="Previous" />

<asp:Button ID="StepNextButton" runat="server" CommandName="MoveNext" Text="Next" />

<asp:Button ID="CancelButton" runat="server" OnClientClick="return confirm('Really Reset?');" CausesValidation="False" CommandName="Cancel"

Text="Reset" />

</StepNavigationTemplate>

<FinishNavigationTemplate>

<asp:Button ID="FinishPreviousButton" runat="server" CausesValidation="False" CommandName="MovePrevious"

Text="Previous" />

<asp:Button ID="FinishButton" runat="server" CommandName="MoveComplete" OnClientClick="return confirm('Are you happy with the Report Schedule?');" Text="Send" />

<asp:Button ID="CancelButton" runat="server" CausesValidation="False" OnClientClick="return confirm('Really Reset?');" CommandName="Cancel"

Text="Reset" />

</FinishNavigationTemplate>

<StartNavigationTemplate>

<asp:Button ID="StartNextButton" runat="server" CommandName="MoveNext" Text="Next" />

<asp:Button ID="CancelButton" runat="server" CausesValidation="False" OnClientClick="return confirm('Really Reset?');" CommandName="Cancel"

Text="Reset" />

</StartNavigationTemplate>

</asp:Wizard>

</div>

</div>

</ContentTemplate>

</atlas:UpdatePanel>

<atlas:UpdateProgress ID="UpdateProgress1" runat="server">

<ProgressTemplate>

<div class="progress">

<img alt="Loading..." src="/app/links/?src=Images/progress.gif" />

Loading...

</div>

</ProgressTemplate>

</atlas:UpdateProgress>

</div>

</form>

</body>

</html

To fix this bug, all you do is change the dropdownlist in step 1 of the wizrd to autopostback=true. This then inserts the __doPostBack javascript into the page.

This should not need to be done and the __doPostback code should be created for the second step only

All Comments

Leave a comment...

  • 1 Comments
    • Hi,

      thanks for posting the repro. This is a known issue (n.2 in theunofficial bug/issue list) and another workaround is to add the following statement in the Page_Load() event handler, to inject the __doPostBack function:

      Page.ClientScript.GetPostBackEventReference(this, String.Empty);

      #1; Sat, 05 Jan 2008 20:24:00 GMT