{"id":7807,"date":"2016-04-26T06:54:15","date_gmt":"2016-04-26T13:54:15","guid":{"rendered":"https:\/\/blogs.plm.automation.siemens.com\/t5\/Solid-Edge-Blog\/How-to-use-SEPartX-ocx-in-ASP-NET-web-application\/ba-p\/344210"},"modified":"2026-03-26T07:17:44","modified_gmt":"2026-03-26T11:17:44","slug":"how-to-use-separtx-ocx-in-asp-net-web-application","status":"publish","type":"post","link":"https:\/\/blogs.sw.siemens.com\/solidedge\/how-to-use-separtx-ocx-in-asp-net-web-application\/","title":{"rendered":"How to use SEPartX.ocx in ASP.NET web application?"},"content":{"rendered":"<p><P>As we all know&nbsp;SEPartX.ocx is a control which can be used in stand alone application. But very few users are aware that SEPartX.ocx can also be used in web based application.<\/P><br \/>\n<P>Follow these steps to&nbsp;use&nbsp;SEPartX.ocx control in an ASP.NET application.<\/P><\/p>\n<p><P>1. Launch the Microsoft Visual Studio 2013 IDE using for e.g. Start -&gt; All Programs -&gt; Visual Studio 2013 -&gt; Visual Studio 2013.<\/P><\/p>\n<p><P>2. After starting Visual Studio create a new ASP.NET Web Application project in Visual Basic .NET using below steps.<\/P><br \/>\n<P>a) On the &#8220;FILE&#8221; menu, click New, and then click Project.<\/P><br \/>\n<P><span class=\"lia-inline-image-display-wrapper lia-image-align-inline\" style=\"width: 999px;\"><img decoding=\"async\" src=\"http:\/\/blogs.sw.siemens.com\/wp-content\/uploads\/sites\/8\/2019\/09\/FileNew-1.png\" alt=\"FileNew.png\" title=\"FileNew.png\" \/><\/span><\/P><\/p>\n<p><P>(b) On the &#8220;New ASP.NET Project&#8221; dialog, click &#8220;Web Forms&#8221; as shown below.<\/P><br \/>\n<P><span class=\"lia-inline-image-display-wrapper lia-image-align-inline\" style=\"width: 963px;\"><img decoding=\"async\" src=\"http:\/\/blogs.sw.siemens.com\/wp-content\/uploads\/sites\/8\/2019\/09\/WebForms-1.png\" alt=\"WebForms.png\" title=\"WebForms.png\" \/><\/span><\/P><\/p>\n<p><P>(c) On the &#8220;New Project&#8221; dialog, click\/expand &#8220;Installed&#8221;, &#8220;Templates&#8221;, &#8220;Other Languages&#8221;, &#8220;Visual Basic&#8221;<\/P><br \/>\n<P>(d) Click\/Select &#8220;ASP.NET Web Forms Application&#8221; Template.<\/P><br \/>\n<P>(e) Type the &#8220;SEPartXWebApp&#8221; Project Name string in the &#8220;Name:&#8221; field of the &#8220;New Project&#8221; dialog. This &#8220;SEPartXWebApp&#8221; will be automatically used and updated in the &#8220;Solution name:&#8221; field of the &#8220;New Project&#8221; dialog.<\/P><br \/>\n<P>(f) Use the &#8220;Browse&#8230;&#8221; button in front of the &#8220;Location:&#8221; field of the &#8220;New Project&#8221; dialog and select the folder to store the Project for e.g. &#8220;E:SEPartXWebAppDemo&#8221;.<\/P><br \/>\n<P>(g) Check the &#8220;Create directory for solution&#8221; checkbox (if not already checked) on the &#8220;New Project&#8221; dialog and click the &#8220;OK&#8221; button of the dialog.<\/P><\/p>\n<p><P><span class=\"lia-inline-image-display-wrapper lia-image-align-inline\" style=\"width: 999px;\"><img decoding=\"async\" src=\"http:\/\/blogs.sw.siemens.com\/wp-content\/uploads\/sites\/8\/2019\/09\/FileNew2-1.png\" alt=\"FileNew2.png\" title=\"FileNew2.png\" \/><\/span><\/P><\/p>\n<p><P>3) You will now have an default Web Form &#8220;Default.aspx&#8221; displayed in the Microsoft Visual Studio IDE. The HTML version of the page will be automatically displayed to you, if not, click the &#8220;Source&#8221; button near the lower left corner of the Design window.<BR \/><BR \/> 4) Replace all the existing code in the &#8220;Default.aspx&#8221; with the following code:<\/P><br \/>\n<PRE>&lt;%@ Page SmartNavigation=&#8221;true&#8221; Language=&#8221;vb&#8221; AutoEventWireup=&#8221;false&#8221; CodeBehind=&#8221;Default.aspx.vb&#8221; Inherits=&#8221;SEPartXWebApp.WebForm1&#8243; %&gt;<\/p>\n<p>&lt;!DOCTYPE HTML PUBLIC &#8220;-\/\/W3C\/\/DTD HTML 4.0 Transitional\/\/EN&#8221;&gt;<\/p>\n<p>&lt;html xmlns=&#8221;http:\/\/www.w3.org\/1999\/xhtml&#8221;&gt;<br \/>\n&lt;head id=&#8221;Head1&#8243; runat=&#8221;server&#8221;&gt;<br \/>\n    &lt;title&gt;SEPartX Viewer Control&lt;\/title&gt;<br \/>\n&lt;\/head&gt;<br \/>\n&lt;body&gt;<br \/>\n    &lt;form id=&#8221;form1&#8243; runat=&#8221;server&#8221;&gt;<br \/>\n    &lt;div&gt;<br \/>\n        &lt;asp:Label ID=&#8221;lblSEPartxView&#8221; runat=&#8221;server&#8221;&gt;&lt;\/asp:Label&gt;<br \/>\n    &lt;\/div&gt;<br \/>\n    &lt;\/form&gt;<br \/>\n&lt;\/body&gt;<br \/>\n&lt;\/html&gt;<\/PRE><br \/>\n<P>5) Click On the &#8220;VIEW&#8221; menu, select &#8220;Code&#8221; OR use the keyboard shortcut (Ctrl+Alt+0) so that the &#8220;Default.aspx.vb&#8221; code window is displayed in the Microsoft Visual Studio IDE.<BR \/><BR \/> 6) Replace all the existing code in the &#8220;Default.aspx.vb&#8221; with the following code.<\/P><\/p>\n<p><PRE>Imports System<\/p>\n<p>Public Class WebForm1<br \/>\n    Inherits System.Web.UI.Page<\/p>\n<p>    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load<\/p>\n<p>        &#8216; Store the filename to be displayed in the SEPartX ActiveX Control in strFilename variable<br \/>\n        Dim strFilename As String = &#8220;C:\\TestPartCP.par&#8221;<\/p>\n<p>        Try<br \/>\n            &#8216; Check if the filename exists. If true call the ViewInputFile procedure to display the<br \/>\n            &#8216; file in the SEPartX ActiveX Control, else display appropriate error message to the user<br \/>\n            &#8216; that the file doe not exist.<br \/>\n            If My.Computer.FileSystem.FileExists(strFilename) = True Then<br \/>\n                ViewInputFile(strFilename)<br \/>\n            Else<br \/>\n                MsgBox(&#8220;The file : &#8221; &amp; strFilename &amp; &#8221; does not exist. Please set a valid filename.&#8221;)<br \/>\n            End If<\/p>\n<p>        Catch ex As Exception<br \/>\n            &#8216;do nothing<br \/>\n        End Try<br \/>\n    End Sub<\/p>\n<p>    Public Sub ViewInputFile(ByVal strFilename As String)<\/p>\n<p>        &#8216; Create the OBJECT tag with the various attributes for the SEPartX ActiveX Control and<br \/>\n        &#8216; set it to the label&#8217;s TEXT property i.e. lblSEPartxView.Text<br \/>\n        lblSEPartxView.Text = &#8221; &lt;OBJECT id=&#8217;separtx&#8217; style=&#8217;LEFT:10px; WIDTH:100%; TOP:10px; HEIGHT:100%&#8217; &#8221;<br \/>\n        lblSEPartxView.Text += &#8220;align=&#8217;middle&#8217; classid=&#8217;clsid:E03935A5-FBAD-11D0-8AC7-0800362FB302&#8242; VIEWASTEXT &gt;&#8221;<br \/>\n        lblSEPartxView.Text += &#8220;&lt;PARAM NAME=&#8217;BackColor&#8217; VALUE=&#8217;14466712&#8242;&gt;&#8221; &#8216; set the default 3D fileype color<br \/>\n        lblSEPartxView.Text += &#8220;&lt;PARAM NAME=&#8217;BackColor2D&#8217; VALUE=&#8217;12632256&#8242;&gt;&#8221; &#8216; set the default 2D fileype color<br \/>\n        lblSEPartxView.Text += &#8220;&lt;PARAM NAME=&#8217;BorderStyle&#8217; VALUE=&#8217;0&#8242;&gt;&#8221; &#8216; set the border style<br \/>\n        lblSEPartxView.Text += &#8220;&lt;PARAM NAME=&#8217;PartFile&#8217; VALUE='&#8221; &amp; strFilename &amp; &#8220;&#8216;&gt;&#8221; &#8216; set the filename<br \/>\n        lblSEPartxView.Text += &#8220;&lt;PARAM NAME=&#8217;ViewType&#8217; VALUE=&#8217;iso&#8217;&gt;&#8221; &#8216; set the view projection type<br \/>\n        lblSEPartxView.Text += &#8220;&lt;PARAM NAME=&#8217;MouseAction&#8217; VALUE=&#8217;none&#8217;&gt;&#8221; &#8216; set the mouse dynamics operation<br \/>\n        lblSEPartxView.Text += &#8220;&lt;PARAM NAME=&#8217;ViewPerspective&#8217; VALUE=&#8217;0&#8242;&gt;&#8221; &#8216; set the flag which indicates if file is to be displayed in perspective projection or not<br \/>\n        lblSEPartxView.Text += &#8220;&lt;PARAM NAME=&#8217;ShowToolbar&#8217; VALUE=&#8217;1&#8242;&gt;&#8221; &#8216; set the flag indicating if the toolbar is displayed or not<br \/>\n        lblSEPartxView.Text += &#8220;&lt;\/OBJECT&gt;&#8221;<\/p>\n<p>    End Sub<br \/>\nEnd Class<\/PRE><br \/>\n<P>7) Modify the value of the strFilename String variable to point to the valid file on your machine which you want view in the SEPartX ActiveX Control for e.g. as below:<BR \/><BR \/> Dim strFilename As String = &#8220;<FONT color=\"maroon\">C:\\TestPartCP.par<\/FONT>&#8220;<BR \/><BR \/> 8) Click On the &#8220;BUILD&#8221; menu, select &#8220;Build Solution&#8221; OR use the keyboard shortcut (F7) to build the &#8220;SEPartXWebApp&#8221; Project.<BR \/><BR \/> 9) Click On the &#8220;DEBUG&#8221; menu, select &#8220;Start Debugging&#8221; OR use the keyboard shortcut (F5) to run\/execute the &#8220;SEPartXWebApp&#8221; Project. This will display webpage with the SEPartX.ocx ActiveX control displaying the User specified file.<BR \/><BR \/> 10) You can modify the value of the strFilename String variable if you want to view a different file in the SEPartX ActiveX Control.<\/P><\/p>\n<p><P>If you could not use SEPartX.ocx in web based application then you can give a try now.<\/P><\/p>\n","protected":false},"excerpt":{"rendered":"<p>As we all know&nbsp;SEPartX.ocx is a control which can be used in stand alone application. But very few users are aware that SEPartX.ocx can also be used in web based application.<br \/>\n Follow these step&#8230;<\/p>\n","protected":false},"author":56576,"featured_media":7815,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spanish_translation":"","french_translation":"","german_translation":"","italian_translation":"","polish_translation":"","japanese_translation":"","chinese_translation":"","footnotes":""},"categories":[1],"tags":[],"industry":[],"product":[],"coauthors":[],"class_list":["post-7807","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-news"],"featured_image_url":"https:\/\/blogs.sw.siemens.com\/wp-content\/uploads\/sites\/8\/2019\/09\/WebForms-1.png","_links":{"self":[{"href":"https:\/\/blogs.sw.siemens.com\/solidedge\/wp-json\/wp\/v2\/posts\/7807","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.sw.siemens.com\/solidedge\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.sw.siemens.com\/solidedge\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.sw.siemens.com\/solidedge\/wp-json\/wp\/v2\/users\/56576"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.sw.siemens.com\/solidedge\/wp-json\/wp\/v2\/comments?post=7807"}],"version-history":[{"count":4,"href":"https:\/\/blogs.sw.siemens.com\/solidedge\/wp-json\/wp\/v2\/posts\/7807\/revisions"}],"predecessor-version":[{"id":7817,"href":"https:\/\/blogs.sw.siemens.com\/solidedge\/wp-json\/wp\/v2\/posts\/7807\/revisions\/7817"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blogs.sw.siemens.com\/solidedge\/wp-json\/wp\/v2\/media\/7815"}],"wp:attachment":[{"href":"https:\/\/blogs.sw.siemens.com\/solidedge\/wp-json\/wp\/v2\/media?parent=7807"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.sw.siemens.com\/solidedge\/wp-json\/wp\/v2\/categories?post=7807"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.sw.siemens.com\/solidedge\/wp-json\/wp\/v2\/tags?post=7807"},{"taxonomy":"industry","embeddable":true,"href":"https:\/\/blogs.sw.siemens.com\/solidedge\/wp-json\/wp\/v2\/industry?post=7807"},{"taxonomy":"product","embeddable":true,"href":"https:\/\/blogs.sw.siemens.com\/solidedge\/wp-json\/wp\/v2\/product?post=7807"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/blogs.sw.siemens.com\/solidedge\/wp-json\/wp\/v2\/coauthors?post=7807"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}