Results 1 to 3 of 3

Thread: How to add vb6 activex component into...

  1. #1

    Thread Starter
    Banned jhermiz's Avatar
    Join Date
    Jun 2002
    Location
    Antarctica
    Posts
    2,492

    How to add vb6 activex component into...

    im creating a activex component in vb6.0 which sends tasks.
    I want to utilize this activex control on an ASP.net web page...

    Lets say I ve created the ocx (compiled it) and what not..and I go into Visual Studio.net...I create a new project..I have webform1.aspx...I want to add this user control activex from vb6.0 to this page...what files do I need to "add". How do I add this user control.

    Also after adding it how do I call a property or method of it...
    I have been trying to do this with some problems. I cannot seem to figure out how to physically add this active x component into vs.net.

    Anyone with some info please

    (Posting this in vb.net and asp.net since they are all related)

    Thanks,
    Jon

  2. #2

    Thread Starter
    Banned jhermiz's Avatar
    Join Date
    Jun 2002
    Location
    Antarctica
    Posts
    2,492

    Re: How to add vb6 activex component into...

    If it helps here is my code in vb6.0

    First off I refernece outlook olb 10.0 or 11.0 one of those forget...

    I needed some properties to store the name, subject, body, and to fields:

    VB Code:
    1. Option Explicit
    2. Private strSubject As String
    3. Private strBody As String
    4. Private strResp As String
    5. Private strOptional As String

    Then I created let's and gets for setting and retreiving these properties

    VB Code:
    1. Public Property Let Subject(Value As String)
    2. strSubject = Value
    3. End Property
    4.  
    5. Public Property Get Subject() As String
    6. Subject = strSubject
    7. End Property
    8.  
    9. Public Property Let Body(Value As String)
    10. strBody = Value
    11. End Property
    12.  
    13. Public Property Get Body() As String
    14. Body = strBody
    15. End Property
    16.  
    17. Public Property Let Responsible(Value As String)
    18. strResp = Value
    19. End Property
    20.  
    21. Public Property Get Responsible() As String
    22. Responsible = strResp
    23. End Property
    24.  
    25. Public Property Let OptionalResponsible(Value As String)
    26. strOptional = Value
    27. End Property
    28.  
    29. Public Property Get OptionalResponsible() As String
    30. OptionalResponsible = strOptional
    31. End Property

    Then I create task...NOTE that I am just testing right now so code might not be elite

    VB Code:
    1. Public Sub CreateTask()
    2. On Error GoTo Err_Handler
    3.  
    4. Dim NameSpace As Object
    5. Dim EmailSend As TaskItem   'for the task
    6. Dim EmailApp As Object
    7.    
    8.     Set EmailApp = CreateObject("Outlook.Application")    'using the outlook object
    9.     Set NameSpace = EmailApp.GetNamespace("MAPI")
    10.     Set EmailSend = EmailApp.CreateItem(3)  '3 = an outlook task
    11.  
    12.     EmailSend.Subject = "test"
    13.     EmailSend.Body = "test"
    14.    
    15.     EmailSend.Recipients.Add (strResp) 'add the recipient
    16.      
    17.     EmailSend.Assign   'assign task to recipient
    18.  
    19.     EmailSend.Send  'send the task
    20.  
    21.     MsgBox "The request has been e-mailed successfully to '" & strResp & "'.", vbInformation, "Request Sent Successfully"
    22.  
    23. Done:
    24. Set EmailSend = Nothing
    25. Set NameSpace = Nothing
    26. Set EmailApp = Nothing
    27. Exit Sub
    28.  
    29. Err_Handler:
    30. MsgBox Err.Description, vbCritical, "Error #: " & Err.Number
    31. Resume Done
    32.  
    33. End Sub


    Then I just created a button to call it

    VB Code:
    1. Private Sub Command1_Click()
    2. strResp = "[email protected]"
    3. CreateTask
    4. End Sub

    Ideally once I get this working for this cheap example Ill use the properties get / let to pass text from web controls to these entities and have it send the task.

    So if someone can even please use my code and maybe post their entire VS.net solution as an aspx project. Or even give me some steps in getting this to work.

    Woka anyone I know you're out there!

    Thanks,

  3. #3

    Thread Starter
    Banned jhermiz's Avatar
    Join Date
    Jun 2002
    Location
    Antarctica
    Posts
    2,492
    ok...

    Found out how to add it to the tool bar...so I drag and drop it...and its on my page now...

    Now lets say I create a button in asp.net. And I want to call this java script function...its just not working.

    Here is my code behind for the aspx page:

    VB Code:
    1. Imports Project1
    2. Public Class WebForm1
    3.     Inherits System.Web.UI.Page
    4.  
    5. #Region " Web Form Designer Generated Code "
    6.  
    7.     'This call is required by the Web Form Designer.
    8.     <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
    9.  
    10.     End Sub
    11.     Protected WithEvents Button1 As System.Web.UI.WebControls.Button
    12.  
    13.     'NOTE: The following placeholder declaration is required by the Web Form Designer.
    14.     'Do not delete or move it.
    15.     Private designerPlaceholderDeclaration As System.Object
    16.  
    17.     Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
    18.         'CODEGEN: This method call is required by the Web Form Designer
    19.         'Do not modify it using the code editor.
    20.         InitializeComponent()
    21.     End Sub
    22.  
    23. #End Region
    24.     Protected p As UserControl1
    25.     Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    26.         'Put user code to initialize the page here
    27.         Me.Button1.Attributes.Add("onClick()", "doStuff();")
    28.     End Sub
    29.  
    30.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    31.  
    32.     End Sub
    33. End Class

    Finally here is the HTML

    VB Code:
    1. <%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm1.aspx.vb" Inherits="WebApplication2.WebForm1"%>
    2. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    3. <HTML>
    4.     <HEAD>
    5.         <title>WebForm1</title>
    6.         <meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
    7.         <meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
    8.         <meta name="vs_defaultClientScript" content="JavaScript">
    9.         <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
    10.     </HEAD>
    11.     <body MS_POSITIONING="GridLayout">
    12.         <form id="Form1" method="post" runat="server">
    13.             <OBJECT id="myActiveX" style="Z-INDEX: 101; LEFT: 48px; POSITION: absolute; TOP: 88px" classid="clsid:CD116C7E-1D49-4B29-9660-68B715DEB4CD"
    14.                 VIEWASTEXT>
    15.                 <PARAM NAME="_ExtentX" VALUE="8467">
    16.                 <PARAM NAME="_ExtentY" VALUE="2381">
    17.             </OBJECT>
    18.             <asp:Button id="Button1" style="Z-INDEX: 102; LEFT: 312px; POSITION: absolute; TOP: 56px" runat="server"
    19.                 Text="Button"></asp:Button>
    20.             <script language="javascript">
    21.                                     <!--
    22.                                     function doStuff()
    23.                                     {                                  
    24.                                         myActiveX.Subject = "The subject or a reference to a subject text box"
    25.                                         myActiveX.Body = "the body or a reference again"
    26.                                         myActiveX.CreateTask  
    27.                                     }
    28.                                     -->
    29.             </script>
    30.             </FONT>
    31.         </form>
    32.     </body>
    33. </HTML>

    So I put in a break point and it goes to the page load and adds that attribute. Any time I click the button it just does a post back going into the page load event.

    Is the function even working cause it doesnt seem like its "Creating a task" via the create task method...if i place a button in the actual activex vb6 user control and click that button it works...but when I click the button on the asp.net page nothing...its like that JS just never runs...I just get a post back. The browser gives me a message also saying are u sure u want to run this active x component which I click yes..but nothing...

    Please advise, I am very close to getting this. As soon as I get it I am gonna write up instructions and feed the community.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width