Hi,
I've got 2 WARP panels on a web page:
At run time I want to dynamically load a web user control based on URL parameters into the panel on the right but I need the user control to update the grid on the left. Does anyone know if this is possible? At the moment I can load the control but when I click the button on it the control disappears and the button's click event is not raised.
I did wonder whether an alternative would be to put the WARP panel into the user control itself and load the user control into a table cell on the right. Again I can't get this to work. In this case the button's click even is raised ok (in which I update a record in a database table) but I can't get the grid in the left panel to update (this grid shows the records from the database table).
If I load all the controls at run time everything is fine.
Many thanks - Nick.
I wrote a sample for you which "persists" a dynamically added control and its value.Note: that is not related to WARP or any other control, but general approach.
aspx:
<igmisc:WebAsyncRefreshPanel ID="WebAsyncRefreshPanel1" runat="server"> <asp:Button ID="LocalSubmit" runat="server" Text="LocalSubmit" /> <asp:Button ID="AddText" runat="server" Text="AddText" onclick="AddText_Click" /> <asp:Panel ID="Panel1" runat="server"></asp:Panel></igmisc:WebAsyncRefreshPanel><asp:Button ID="FullSubmit" runat="server" Text="FullSubmit" />
aspx.cs:
protected void Page_Load(object sender, EventArgs e) { System.Collections.Specialized.NameValueCollection form = this.Request.Form; if(form == null) return; string newValue = form["NewTextBoxID"]; if(newValue != null) { TextBox tb = new TextBox(); tb.ID = "NewTextBoxID"; tb.Text = newValue; this.Panel1.Controls.Add(tb); } } protected void AddText_Click(object sender,EventArgs e) { Control tb = this.Panel1.FindControl("NewTextBoxID"); if(tb != null) return; tb = new TextBox(); tb.ID = "NewTextBoxID"; ((TextBox)tb).Text = "Old Value"; this.Panel1.Controls.Add(tb); }
Hi Victor,
Do you have any sample code about how to solve this problem? I am adding text boxes in run
time to the table that resides inside in WARP panel.
When my data changing, these text boxes still have old value when I refresh panel
and feed new data using ContentRefresh event.
I can see new values when I close and open page again.
This problem still exists even when I completely rebuild table after post back
Thanks
Hello I believe I am having the same problem.. We have UltraWebGrids inside of User Controls that are added to a .NET Panel at runtime based on some condition.
The explanation above seems very technical and logical, however why does the page perform normally when changing criteria from controls OUTSIDE the panel? For instance when changing the date of the report, the ajax loader shows, the report refreshes with the new date.. All is well..
When changing the type of report, the type changes, the report refreshes without incident. But when clicking on anything INSIDE the panel (such as paging), the panel just disappears. Is there any way around this?
Hi Nick,
If you add children (like UserControl or whatever) in WARP on a particular condition at run time, then after a postback those child controls including all their events will be lost. Because dot-net does not support persistance of dynamic controls and it is not able to recreate them and associate events with them. However, all information about those children, their new values and their events actually exist and can be obtained. But that is not a standard and needs a lot of manual work. To start with you may debug content of Requiest.Form and other objects.