I am building an ASP.NET application and have just encountered something very
strange which I would like explained if possible.
In BaseForm.ascx I have the following <form> element:
<form ID="formBaseForm" method="post" runat="server">
<!-- Banner UserControl -->
<PW:Banner runat="server" ID="Banner1" />
<!-- Initial UserControl -->
<PW:Initial runat="server" ID="Initial1" />
<!-- Content Section -->
<table border="1" width="95%" cellpadding="2" cellspacing="0">
<tr>
<td>
<!-- content goes here -->
<asp:PlaceHolder id="_placeHolder" runat="server" />
</td>
</tr>
</table>
</form>
The unexpected behaviour occurs in the Initial UserControl where I have a
similar table to the one above with four DropDownLists, two of which have
AutoPostBack set to True.
When I do a GET request to an .aspx page that Inherits from BaseForm (and
thus renders the UserControl) and do View | Source, I can see a <SCRIPT>
block in the <body> with the expected __dopostback function, I can also see
the onchange events on the two <select> tags wired up to __dopostback.
When I select another value in one of the DropDownLists where AutoPostback
is True, thus invoking onchange which calls the __dopostback, something
happens which looks like a postback but I don't think is because a breakpoint
in my page_load is not hit. When I do View | Source, I see the <selects>
onchange is still pointing to __dopostback but the entire <SCRIPT> block does
not appear anywhere. When I select another value in one of the DropDownLists
now, I get a JavaScript error "Object expected" because obviously there is
now no __dopostback function.
This only happens when I have the following at the top of Initial.ascx:
<%@ OutputCache Duration="3600" VaryByParam="none" %>
The trouble is I haven't the faintest idea why...
Cheers,
Pete