loadcontrol

Getting data from child controls loaded programmatically

半世苍凉 提交于 2020-01-07 06:43:22
问题 I've created 2 controls to manipulate a data object: 1 for viewing and another for editing. On one page I load the "view" UserControl and pass data to it this way: ViewControl control = (ViewControl)LoadControl("ViewControl.ascx"); control.dataToView = dataObject; this.container.Controls.Add(control); That's all fine and inside the control I can grab that data and display it. Now I'm trying to follow a similar approach for editing. I have a different User Control for this (with some textboxes

Panel and User Controls vs load User Controls dynamically

半腔热情 提交于 2019-12-12 14:01:47
问题 If I want to dynamically show or hide several User Controls. Would it be better to use Panels that load the User Controls and then show or hide the Panels (visible=true/false) or would it be better to use a PlaceHolder and load (add) or unlaod(clear) them at runtime (LoadControl())? a) I have a page that uses AJAX UpdatePanel. The page has 10 Panels, each Panel loads a User Control. In code behind I make the a Panel visible or invisible, only show one at a time. This solution is simple, as

How to LoadControl a control that uses VaryByControl OutputCache, specifying values for properties

青春壹個敷衍的年華 提交于 2019-12-10 13:54:03
问题 I've got a user control that should use caching, with VaryByControl . The .ascx file looks like this : <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="TestControl.ascx.cs" Inherits="mynamespace.TestControl" %> <%@ OutputCache Duration="10" Shared="true" VaryByControl="Test" %> <p id="SomeText" runat="server">Nothing</p> The TestControl class in the code-behind file has a int Test {...} property and an Page_Load() event handler that fills the SomeText paragraph with: SomeText

How do I stop HtmlEditorExtender encoding html in postback?

喜你入骨 提交于 2019-12-01 22:49:00
问题 I have a user control that contains a text box, an HtmlEditorExtender , and a button. The user control is loaded into a parent page using LoadControl() . Whenever I click on the button to post the form, any formatted text in the text box gets encoded, which is not what should happen. For example, if I load the text control with <p>test</p> after I click on the button to post the page, the text returned by the .Text property is &lt;p&gt;test&lt;/p&gt; If I post a second time, it is further

How do I stop HtmlEditorExtender encoding html in postback?

本小妞迷上赌 提交于 2019-12-01 21:27:08
I have a user control that contains a text box, an HtmlEditorExtender , and a button. The user control is loaded into a parent page using LoadControl() . Whenever I click on the button to post the form, any formatted text in the text box gets encoded, which is not what should happen. For example, if I load the text control with <p>test</p> after I click on the button to post the page, the text returned by the .Text property is &lt;p&gt;test&lt;/p&gt; If I post a second time, it is further encoded as: &amp;lt;p&amp;gt;test&amp;lt;/p&amp;gt; and so on. I confirmed that the control works fine

Asp.net Usercontrol LoadControl Issue

一世执手 提交于 2019-11-27 22:11:20
I am having an issue when using LoadControl( type, Params ) . Let me explain... I have a super simple user control (ascx) <%@ Control Language="C#" AutoEventWireup="True" Inherits="ErrorDisplay" Codebehind="ErrorDisplay.ascx.cs" EnableViewState="false" %> <asp:Label runat="server" ID="lblTitle" /> <asp:Label runat="server" ID="lblDescription" /> with code ( c# ) behind of: public partial class ErrorDisplay : System.Web.UI.UserControl { private Message _ErrorMessage; public ErrorDisplay() { } public ErrorDisplay(Message ErrorMessage) { _ErrorMessage = ErrorMessage; } protected override void

Asp.net Usercontrol LoadControl Issue

一世执手 提交于 2019-11-26 20:56:33
问题 I am having an issue when using LoadControl( type, Params ) . Let me explain... I have a super simple user control (ascx) <%@ Control Language="C#" AutoEventWireup="True" Inherits="ErrorDisplay" Codebehind="ErrorDisplay.ascx.cs" EnableViewState="false" %> <asp:Label runat="server" ID="lblTitle" /> <asp:Label runat="server" ID="lblDescription" /> with code ( c# ) behind of: public partial class ErrorDisplay : System.Web.UI.UserControl { private Message _ErrorMessage; public ErrorDisplay() { }