
December 2nd, 2004, 11:07 PM
|
|
Registered User
|
|
Join Date: Dec 2004
Posts: 2
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
vb.net usercontrol in web page
I need to have a .net usercontrol based on some code I have to work with a serial port to run within a web form, accepting input through a method and raising an event which will call a javascript event handler within the page.
As a start I was just going to write a simple one that displays a message box and works with a javascript event handler. I can get the control to display properly and calling the methods for the control work just fine but I can't get events to work with the javascript event handler. In my latest iteration I've tried using the ComClassAttribute and a funny thing happened. Just for the heck of it I tried using the clsid:<guid> for the classid instead of the normal syntax for a .NET control and it worked. But not a real good solution for deploying it, especially when I know other people are getting it to work without doing that. I've also enabled full authority for both the assembly as well as put the site in my trusted sites and enabled full authority for trusted sites. I'm going nuts here.
Thanks in advance,
Dave
Here's my code for my control:
Code:
<ComClass(DeviceController.ClassId, DeviceController.InterfaceId, DeviceController.EventsId)> _
Public Class DeviceController
#Region "COM GUIDs"
' These GUIDs provide the COM identity for this class
' and its COM interfaces. If you change them, existing
' clients will no longer be able to access the class.
Public Const ClassId As String = "F2BCEC96-E846-4B47-8EBF-2E84A3E97AA4"
Public Const InterfaceId As String = "8B0D4B7B-21CB-41FB-8BD2-55465C3CE94B"
Public Const EventsId As String = "6F0C0CC3-1F08-43A5-B406-89E6FF739FD2"
#End Region
' A creatable COM class must have a Public Sub New()
' with no parameters, otherwise, the class will not be
' registered in the COM registry and cannot be created
' via CreateObject.
Public Sub New()
MyBase.New()
End Sub
Public Sub SomeSub()
MsgBox("SomeSub")
End Sub
Public Sub RaiseDataReceived()
RaiseEvent DataReceived()
End Sub
Public Event DataReceived()
End Class
and the code on my webform:
Code:
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm1.aspx.vb" Inherits="EclipseWeb.WebForm1"%>
<html>
<head>
<title>WebForm1</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio 7.0">
<meta name=vs_defaultClientScript content="JavaScript">
<meta name=vs_targetSchema content="http://schemas.microsoft.com/intellisense/ie5">
<script for="userControl11" event="DataReceived" language="javascript">
alert("Hello!");
</script>
</head>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<object id="userControl11" classid="EclipseDevCtl.dll#EclipseDevCtl.DeviceController" VIEWASTEXT>
</object>
<br><br>
<button id=btnTest2 onclick="document.all.userControl11.SomeSub()">Click Me</button>
<br>
<button id=btnTest3 onclick="document.all.userControl11.RaiseDataReceived()">Click Me 2</button><br><br>
</form>
</body>
</html>
|