Nov 04, 2015, 7:52 AM
[CLOSED] Get a Panel's dynamic HTML from code behind
Hello,
I have a Panel where I set the HTML dynamically from code behind on the click of a button. Through another event I want to get the HTML, however the HTML attribute is always empty.
Please see below an example. Click on the first button to add the HTML to the Panel. And then click on the second button to get the HTML.
I have a Panel where I set the HTML dynamically from code behind on the click of a button. Through another event I want to get the HTML, however the HTML attribute is always empty.
Please see below an example. Click on the first button to add the HTML to the Panel. And then click on the second button to get the HTML.
<%@ Page Language="C#" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<!DOCTYPE html>
<html>
<head>
<title></title>
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
}
[DirectMethod]
public void AddHTML()
{
Panel1.Html = "<div>This is a test html</div>";
}
[DirectMethod]
public void GetHTML()
{
string html = Panel1.Html; //returns empty string
}
</script>
</head>
<body>
<form id="Form1" runat="server">
<ext:ResourceManager ID="ResourceManager1" runat="server" />
<ext:Panel ID="Panel1" runat="server" Width="500" Height="500" Title="HTML Panel">
</ext:Panel>
<ext:Button runat="server" Text="Add HTML">
<Listeners>
<Click Handler="App.direct.AddHTML();" />
</Listeners>
</ext:Button>
<ext:Button runat="server" Text="Get HTML">
<Listeners>
<Click Handler="App.direct.GetHTML();" />
</Listeners>
</ext:Button>
</form>
</body>
</html>
Also, I'd like to avoid using a Hidden field to store the HTML inside, as the generated html can get quite big.
Last edited by Daniil; Nov 05, 2015 at 8:23 AM.
Reason: [CLOSED]