本文介绍了如何将DLL类设置为项目的代码隐藏文件..?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我有2个文本框和4个按钮的页面 <%@ 控制 语言 = C# AutoEventWireup = true CodeBehind = DllController.ascx.cs 继承 = SampleDll.DllController %> < div > < asp:TextBox ID = txtFirst runat = 服务器 > ; 0 < / asp:TextBox > < / div > < div > < asp:TextBox ID = txtSecond runat = server > 0 < / asp:TextBox > < / div > < div > < asp:按钮 ID = btnAdd runat = server 文字 = 添加 OnClick = btnAdd_Click OnClientClick = btnAdd_Click 宽度 = 42px / > < asp:按钮 ID = btnSubtract runat = server 文字 = Sub OnClick = btnSubtract_Click 宽度 = 42px / > < asp:按钮 ID = btnMultiple runat = server 文字 = Mul OnClick = btnMult_Click 宽度 = 42px / > < asp:按钮 ID = btnDivide runat = 服务器 文字 = Div OnClick = btnDivide_Click 宽度 = 42px / > < / div > 我有一个DLL类 使用系统; 使用 System.Collections.Generic; 使用 System.Linq; 使用 System.Text; 命名空间 WrappesrSample { public class WrapSample { public WrapSample() { } public int 添加( int 首先, int 秒) { WrapSample.inside obj = new WrapSample.inside(); int sum = obj。 add (First,Second); return sum; } public int Sub( int 首先, int 秒) { WrapSample.inside obj = new WrapSample.inside(); int sum = obj.Sub(First,Second); return sum; } public int Mul( int 首先, int 秒) { WrapSample.inside obj = new WrapSample.inside(); int sum = obj.Mul(First,Second); return sum; } public void Div( int 首先, int 其次, out int res, out int rem) { WrapSample。在obj = new WrapSample.inside(); obj.Div(第一,第二, out res, out rem); } 私人 类 { public int add ( int x, int y) { return x + y; } public int Sub( int x, int y) { return x - y; } public int Mul( int x, int y) { return x * y; } public void Div( int x, int y, out int Res, out int rem) { Res = x / y; rem = x%y; } } } } Dll类的名称是包装样本。 现在我想将My Dll类设置为Page后面的代码。 如何添加解决方案 帮助链接到你: 如何将DLL用作文件后面的代码 [ ^ ] I have Page with 2 text boxes and 4 buttons<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="DllController.ascx.cs" Inherits="SampleDll.DllController" %><div> <asp:TextBox ID="txtFirst" runat="server">0</asp:TextBox></div><div> <asp:TextBox ID="txtSecond" runat="server">0</asp:TextBox></div><div> <asp:Button ID="btnAdd" runat="server" Text="Add" OnClick="btnAdd_Click" OnClientClick="btnAdd_Click" Width="42px" /> <asp:Button ID="btnSubtract" runat="server" Text="Sub" OnClick="btnSubtract_Click" Width="42px" /> <asp:Button ID="btnMultiple" runat="server" Text="Mul" OnClick="btnMult_Click" Width ="42px" /> <asp:Button ID="btnDivide" runat="server" Text="Div" OnClick="btnDivide_Click" Width="42px" /> </div>And I have a DLL class using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace WrappesrSample{ public class WrapSample { public WrapSample() { } public int Add(int First, int Second) { WrapSample.inside obj = new WrapSample.inside(); int sum = obj.add(First, Second); return sum; } public int Sub(int First, int Second) { WrapSample.inside obj = new WrapSample.inside(); int sum = obj.Sub(First, Second); return sum; } public int Mul(int First, int Second) { WrapSample.inside obj = new WrapSample.inside(); int sum = obj.Mul(First, Second); return sum; } public void Div(int First, int Second, out int res, out int rem) { WrapSample.inside obj = new WrapSample.inside(); obj.Div(First, Second, out res, out rem); } private class inside { public int add(int x, int y) { return x + y; } public int Sub(int x, int y) { return x - y; } public int Mul(int x, int y) { return x * y; } public void Div(int x, int y, out int Res, out int rem) { Res = x / y; rem = x % y; } } } }Name of the Dll class is wrapper sample.Now I want to set My Dll class as the Code behind of the Page.How can I add that 解决方案 Hi, a help link you you:How to Use a DLL as a Code Behind File[^] 这篇关于如何将DLL类设置为项目的代码隐藏文件..?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
11-03 11:58