Monday, March 26, 2012

UpdatePanel & Form View in Web Site Project vs. Web Application Project

I am seeing two different behavour patters when using the UpdatePanel in a Web Application Project (File > Add New Project > ASP.NET AJAX-Enabled Web Application) vs a Web Site Project (File > New Website > ASP.NET AJAX-Enabled Web Site)

The exact same code will complie in one project type but not in another.

The code is:

<

asp:FormViewID="FormView1"runat="server"> <EditItemTemplate> <asp:UpdatePanelID="UpdatePanel1"runat="server"> <ContentTemplate> <asp:LabelID="Label1"runat="server"Text="Label"></asp:Label> </ContentTemplate> </asp:UpdatePanel> </EditItemTemplate> <InsertItemTemplate> <asp:UpdatePanelID="UpdatePanel1"runat="server"> <ContentTemplate> <asp:LabelID="Label1"runat="server"Text="Label"></asp:Label> </ContentTemplate> </asp:UpdatePanel> </InsertItemTemplate></asp:FormView>If you have this code in a single page Web Application Project it will complie and run just fine. However if you have this code in a Web Site Project it will not complete. It complains that you have already declared Label1 in this class. SInce Label1 is inside two different FormView templates this should complie.

Does anyone know a resolution for this other than converting to using Web Application Projects instead of Web Site Projects?

Thanks In Advance
Martin

p.s. Using most recient System.Web.Extensions downalod (1.0.61025.0)

Nevermind. The Web Application Project does not complete the aspx file so it does not fail until you try to run the code.

I guess its another issue as to why the UpdatePanel forces you to rename your controls differently within each template of the formview control.

Martin

No comments:

Post a Comment