Calling a Button Event from a Compiled DLL

80酷酷网    80kuku.com

  'The Inherits Line calls the Namespace.Class inside the DLL
<% Page Language="VB" Inherits="ASPFreeS.MyCodeBehind" %>

<html>
<head>
<title>Calling a Button Event from a compiled DLL</title>
</head>
<body>
   <form runat="server">
    <asp:button id="btnWhatsNew" text="Add Whats new" OnClick="b1_Click" runat="server" />
</form>
</body>
</html>

  
Source VB File that gets compiled  
cpdll.vb file



Option Strict Off

Imports System
Imports System.DateTime
Imports System.Globalization
Imports System.Data
Imports System.Data.SQL
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.HtmlControls

Namespace ASPFreeS


    Public Class MyCodeBehind : Inherits Page

        Public Sub b1_Click(sender As Object , e As System.EventArgs)
             dim value1 as string = "WOW the button was clicked!"
             response.write(value1)
        End Sub
  

    End Class
End Namespace


  
Batch File to compile the DLL(This will place the dll in the /bin directory)

This creates an aspfree.dll into the bin directory!
mk.bat file to compile the .vb file

vbc /t:library /out:..\bin\aspfreebuttoneventdll.dll /r:System.Web.dll /r:System.dll
/r:System.Data.dll cpdll.vb

分享到
  • 微信分享
  • 新浪微博
  • QQ好友
  • QQ空间
点击: