MicroDraw 图形控件在ASP.NET下的使用

如何在ASP.NET中使用MicroDraw图形控件

 
 
 
在ASP.NET中如何使用MicroDraw 图形控件;
 
以下用VS.NET 2005 为例说明使用过程;
 
1. 新建网站,选择 ASP.NET ; 开发语言可以选择自己熟悉的;
 
 
 
 
2. 添加控件; 因为MicroDraw图形控件是运行在客户端的,可以直接在代码中添加控件的classid, 代码如下:
</head>
<body>
    <p>
    <object classid="clsid:8A629F67-E4F6-4A32-8009-0247F8E9ADEE" id="MicroDrawOcx1">
    </object>
    </p>
    <p>
        &nbsp;</p>
    <p>
        <input id="Button2" style="width: 167px; height: 54px" type="button" value="button" onclick="return Button2_onclick()" />&nbsp;</p>
</body>
 
也可以在FornTPage里面添加控件,调整大小,然后将相应的代码COPY过来;
 
 
 
 
 
 
3. 添加方法:
    我们要做个一个按钮,点击这个按钮创建一条直线, 注意添加按钮的时候不要选择服务器按钮,要选择工具箱的HTML栏目的按钮;
    点击按钮后会生成一个 javascript 函数,接下来就在这个函数内完成代码;如下:
 
    function Button2_onclick() {
     MicroDrawOcx1.CreateLine(0,0,100,100);
     MicroDrawOcx1.RedrawAll();
   }
 

 

 

全部代码如下:

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>

<!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 runat="server">
    <title>无标题页</title>
<script language="javascript" type="text/javascript">
// <!CDATA[

function Button2_onclick() {
MicroDrawOcx1.CreateLine(0,0,100,100);
MicroDrawOcx1.RedrawAll();
}

// ]]>
</script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        &nbsp;</div>
    </form>
   
    <p>
    <object classid="clsid:8A629F67-E4F6-4A32-8009-0247F8E9ADEE" id="MicroDrawOcx1" style="width: 511px; height: 252px">
    </object>
    </p>
    <p>
        &nbsp;</p>
    <p>
        <input id="Button1" style="width: 167px; height: 54px" type="button" value="CreateLine" onclick="return Button2_onclick()" />&nbsp;</p>

</body>
</html>

 
posted @ 2009-02-26 19:28  MicroDraw  阅读(861)  评论(0编辑  收藏  举报