Creating a WebFigure on an ASPX Page
There are several ways to use WebFigures on a Web page with
.NET:
Using the WebFigureControl locally
in design mode (the easiest approach)
Using the WebFigureControl remotely
in design mode
Returning an HTML string from the ASPX code behind
which embeds the WebFigure into a page.
Using a WebFigureControl directly
from the ASPX code without utilizing the designer.
In each case, the WebFigure object is stored in the Web server's
cache. The JavaScript that executes the client calls back to the server
for updates and, using the cached WebFigure, new updates are sent
back to the client. For more information on these examples, see the MATLAB Builder NE User's Guide.
Using the WebFigureControl Locally in Design Mode
Drag a WebFigureControl from the Microsoft® Visual Studio® Toolbox
to an ASPX page in design mode. This automatically adds a reference
to WebFigureService to your Web site.
Edit the code behind the site to attach the figure
to the control, as follows:
WebFigure webFigure =
new WebFigure(deployment.getWebFigure());
WebFigureControl1.WebFigure = webFigure;
Using the WebFigureControl Remotely in Design Mode
Drag a WebFigureControl from the Microsoft Visual
Studio Toolbox onto an ASPX page in design mode.
Edit the Properties for this
figure to point it to a Web site that has webfigureservice installed
and that has attached a WebFigure to the cache. This can either be
done using code as shown below or by using the Properties window in
the designer.
//This is the name that was used on the server
// when attaching the WebFigure
WebFigureControl1.Name = "UserPlot";
//By not setting this value it will try and use
// the current web site for all redirection calls
WebFigureControl1.Root = "";
//If you didn't set this or if it was set to unknown
// this would instruct the WebFigureService to look
// through the diferent caches for a WebFigure with
// this specific name.
WebFigureControl1.Scope = WebFigureAttachType.session;
Returning an HTML String from ASPX Code to Embed the WebFigure
into a Page.
This example is very similar to what you can find in Deploying a MATLAB Figure Over the Web Using WebFigures,
but this example also uses the DAO. The middle tier code in Hosting a .NET DAO with ASPX is repeated
here:
WebFigure webFigure = new WebFigure(deployment.getWebFigure());
//First we attach the webfigure to one of ASP.NET's caches,
// in this case, the session cache
Session["SessionStateWebFigure"] = webFigure;
//Now we use a WebFigure Utility to get an HTML
// String that will display this figure, Notice
// how we reference the name we used when attaching
// it to the cache and we indicate
// that the Attach type is session.
String localEmbedString =
WebFigureServiceUtility.GetHTMLEmbedString(
"SessionStateWebFigure",
WebFigureAttachType.session,
300,
300);
Response.Write(localEmbedString);
Using a WebFigureControl Directly from ASPX Code Without Using
the Designer.
To use the WebFigure object directly from an ASPX page, manually
write the code that would otherwise be automatically added to the
ASPX page. Writing the code creates a WebFigure object with your object's
parameters, as in the following example. UserPlot is
the name of the Web object that was placed in the cache by the middle
tier.
<%@ Register Assembly="WebFiguresService, Version=2.8.1.0,
Culture=neutral, PublicKeyToken=e1d84a0da19db86f"
Namespace="MathWorks.MATLAB.NET.WebFigures.Service"
TagPrefix="cc1" %>
<cc1:WebFigureControl
ID="WebFigureControl1"
runat="server"
Height="328px"
Width="399px"
Root=""
Scope="session"
Name="UserPlot"
/>
 | Creating a WebFigure on a JSP Page | | Working with Static Images |  |
Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.
Get the Interactive Kit