UpdatePanelContentTemplateDynamicCS.aspx 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <%@ Page Language="C#" %>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  3. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  4. <script runat="server">
  5. protected void Page_Load(object sender, EventArgs e)
  6. {
  7. UpdatePanel up1 = new UpdatePanel();
  8. up1.ID = "UpdatePanel1";
  9. up1.UpdateMode = UpdatePanelUpdateMode.Conditional;
  10. // The CustomContentTemplate class defines the contents of the UpdatePanel.
  11. ITemplate t = new CustomContentTemplate();
  12. up1.ContentTemplate = t;
  13. Panel1.Controls.Add(up1);
  14. }
  15. </script>
  16. <html xmlns="http://www.w3.org/1999/xhtml">
  17. <head runat="server">
  18. <title>UpdatePanel ContentTemplate Example</title>
  19. </head>
  20. <body>
  21. <form id="form1" runat="server">
  22. <div>
  23. <asp:ScriptManager ID="ScriptManager1"
  24. runat="server" />
  25. <asp:Panel ID="Panel1"
  26. GroupingText="Programmatically Added UpdatePanel"
  27. runat="server" >
  28. </asp:Panel>
  29. <br />
  30. </div>
  31. </form>
  32. </body>
  33. </html>