I'm currently trying to load controls onto the page dynamically and I was trying to use the UpdatePanel so that the controls could load w/o the page refreshing but I'm running into a problem with that. When I click the button that loads the control, it forces a refresh. How do i fix that?
here's the code
<%
@dotnet.itags.org.PageLanguage="C#"AutoEventWireup="true"CodeFile="Default.aspx.cs"Inherits="_Default" %><!
DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.1//EN""http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><
htmlxmlns="http://www.w3.org/1999/xhtml"><
headrunat="server"><title>Untitled Page</title></
head><
body><formid="form1"runat="server"><atlas:ScriptManagerID="ScriptManager1"runat="server"/><asp:ButtonID="btnControl1"runat="server"Text="Load Control 1"CausesValidation="False"OnClick="btnControl1_Click"/><asp:ButtonID="btnControl2"runat="server"Text="Load Control 2"CausesValidation="False"OnClick="btnControl2_Click"/><atlas:UpdatePanelID="udpPanel"runat="server"><ContentTemplate><div><asp:PlaceHolderID="PlaceHolder1"runat="server"></asp:PlaceHolder></div></ContentTemplate><Triggers><atlas:ControlEventTriggerControlID="btnControl1"EventName="Click"/><atlas:ControlEventTriggerControlID="btnControl2"EventName="Click"/></Triggers></atlas:UpdatePanel></form><scripttype="text/xml-script"><page xmlns:script=
"http://schemas.microsoft.com/xml-script/2005"><references>
</references>
<components>
</components>
</page>
</script></
body></
html>ASPX.cs
using
System;using
System.Data;using
System.Configuration;using
System.Web;using
System.Web.Security;using
System.Web.UI;using
System.Web.UI.WebControls;using
System.Web.UI.WebControls.WebParts;using
System.Web.UI.HtmlControls;public
partialclass_Default : System.Web.UI.Page{
protectedvoid Page_Load(object sender,EventArgs e){
}
protectedvoid btnControl1_Click(object sender,EventArgs e){
this.PlaceHolder1.Controls.Add(Page.LoadControl("~/Control1.ascx"));}
protectedvoid btnControl2_Click(object sender,EventArgs e){
this.PlaceHolder1.Controls.Add(Page.LoadControl("~/Control2.ascx"));}
}
Hi,it seems that your aren't setting EnablePartialRendering="True" on the ScriptManager control.
I enabled that and I still couldn't get it to work. Any other suggestions?
I fixed it. I'm not quite sure what I did but it works lol.
No comments:
Post a Comment