Mar 23, 2011, 9:49 PM
Updating Portlet content in DirectMethod
Hi, I have a portlet on a page and I have a user control inside the portlet.
I hooked up the click event of Gear tool of portlet with a DirectMethod.
In direct method I am changing the content of UserControl and I want the updates to show up in the browser without refreshing the whole page.
I tried Render(), Update() and UpdateContent() methods on the portlet. None of them is working.
Any idea how I can achieve this. Please see the attached code:
ASPX Page:
Thanks,
Rao
I hooked up the click event of Gear tool of portlet with a DirectMethod.
In direct method I am changing the content of UserControl and I want the updates to show up in the browser without refreshing the whole page.
I tried Render(), Update() and UpdateContent() methods on the portlet. None of them is working.
Any idea how I can achieve this. Please see the attached code:
ASPX Page:
<%@ Page Language="C#" %>
<%@ Import Namespace="Ext.Net.Utilities" %>
<%@ Register assembly="Ext.Net" namespace="Ext.Net" tagprefix="ext" %>
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
string text = @"Testing to see if portal content can be changed during a DirectMethod";
this.ResourceManager1.RegisterClientScriptBlock("text", string.Format("var text=\"{0}\";", text));
UserControl uc = (UserControl)LoadControl("TestControl.ascx");
uc.ID = "myUC";
Portlet p = new Portlet();
p.ContentControls.Add(uc);
p.Padding = 5;
p.Header = true;
portalColumn1.ContentControls.Add(p);
p.Tools.Add(new Tool(ToolType.Gear, "handleEdit();", "Edit"));
}
[DirectMethod]
public void editPortlet()
{
Portlet p = ControlUtils.FindControls<Portlet>(this)[0];
TestControl tc = (TestControl)p.ContentControls[0];
tc.setName("Test Name");
p.Update();
p.Render();
p.UpdateContent();
}
protected void Portlet_Hide(object sender, DirectEventArgs e)
{
X.Msg.Alert("Status", e.ExtraParams["ID"] + " Hidden").Show();
}
</script>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Portal in TabPanel - Ext.NET Examples</title>
<script type="text/javascript">
function handleEdit()
{
Ext.net.DirectMethods.editPortlet();
}
</script>
</head>
<body>
<ext:ResourceManager ID="ResourceManager1" runat="server" />
<form id="form1" runat="server">
<asp:ScriptManager ID="Scriptmanager1" runat="server" />
<ext:Viewport ID="Viewport1" runat="server">
<Items>
<ext:BorderLayout ID="BorderLayout1" runat="server">
<Center MarginsSummary="5 5 5 0">
<ext:Portal ID="Portal1" runat="server" Border="false" Layout="Column">
<Items>
<ext:PortalColumn ID="portalColumn1"
runat="server"
Cls="x-column-padding"
ColumnWidth=".33"
Layout="Anchor">
<Items>
</Items>
</ext:PortalColumn>
<ext:PortalColumn ID="portalColumn2"
runat="server"
Cls="x-column-padding"
ColumnWidth=".33"
Layout="Anchor">
<Items>
</Items>
</ext:PortalColumn>
<ext:PortalColumn ID="portalColumn3"
runat="server"
Cls="x-column-padding1"
ColumnWidth=".33"
Layout="Anchor">
<Items>
</Items>
</ext:PortalColumn>
</Items>
</ext:Portal>
</Center>
</ext:BorderLayout>
</Items>
</ext:Viewport>
</form>
</body>
</html>
User Control:<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="TestControl.ascx.cs" Inherits="TestControl" %>
<table>
<tr>
<td>
<asp:Label ID="Label1" runat="server" Text="Name"></asp:Label></td>
<td><asp:TextBox ID="txtName" runat="server"></asp:TextBox></td>
</tr>
</table>
User control code behind page:using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class TestControl : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
}
public void setName(String name)
{
this.txtName.Text = name;
}
}
Thanks,
Rao
Last edited by geoffrey.mcgill; Aug 23, 2011 at 3:46 PM.
Reason: please use [CODE] tags