怎么生产dll 文件 --问题

xiaoxiaoxiao8 2010-04-05 05:35:01
是这样的。别人给我一段代码:
叫我生产一个dll 直接调用就可以了。但是我不知道步骤
我用的是vs 2005 我是学做网站的 asp.net C#
using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.ComponentModel;
using System.Collections;

namespace ExtendWebControls
{

[ToolboxData("<{0}:DropDownListExtend runat=\"server\" />")]
public class DropDownListExtend : System.Web.UI.WebControls.TextBox
{
private Hashtable _values;
private DropDownList _DropDownList;

public DropDownListExtend()
{
_values = new Hashtable();
_DropDownList = new DropDownList();
}


public Hashtable Values
{
get{return _values;}
set{_values = value;}
}


protected override void Render(HtmlTextWriter output)
{

int iWidth = Convert.ToInt32(base.Width.Value);
if(iWidth == 0)
{
iWidth = 102;
base.Width = Unit.Parse("102px");
}

int sWidth = iWidth + 16;
int spanWidth = sWidth - 18;

output.Write("<div style=\"POSITION:relative\">");
output.Write("<span style=\"MARGIN-LEFT:" + spanWidth.ToString() + "px;OVERFLOW:hidden;WIDTH:18px\">");

_DropDownList.Width = Unit.Parse(sWidth.ToString() + "px");
_DropDownList.Style.Add("MARGIN-LEFT", "-" + spanWidth.ToString() + "px");
_DropDownList.ID = base.ID + "_Select";
_DropDownList.Attributes.Add("onchange", "this.parentNode.nextSibling.value=this.value");
_DropDownList.Attributes.Add("onfocus", ""+this.getFocusScript()+"");

if(_values.Count > 0)
{
foreach(string key in _values.Keys)
{
ListItem item = new ListItem();

item.Value = key;
item.Text = _values[key].ToString();

_DropDownList.Items.Add(item);
}
}
_DropDownList.RenderControl(output);

output.Write("</span>");

base.Style.Clear();
base.Width = Unit.Parse(iWidth.ToString() + "px");
base.Style.Add("left", "0px");
base.Style.Add("POSITION", "absolute");
base.Render(output);

output.Write("</div>");
}

private string getFocusScript()
{
string strScript = "\n";
strScript += "var isExist = -2;\n";
strScript += "var obj = event.srcElement;\n";
strScript += "var str = this.parentNode.nextSibling.value;\n";
strScript += "var ary = obj.options;\n";
strScript += "for(var i=0;i<ary.length;i++){\n";
strScript += " if(str == ary[i].text){\n";
strScript += " isExist = i;\n";
strScript += " break;\n";
strScript += " }\n";
strScript += "}\n";
strScript += "if(isExist != -2){\n";
strScript += " obj.selectedIndex = isExist;\n";
strScript += "}\n";
strScript += "else{\n";
strScript += " obj.selectedIndex = -1;\n";
strScript += "}\n";

return strScript;
}
}
}
我怎么把这段代码做成一个DLL了。步骤是怎么样。我要详细的步骤。
...全文
85 4 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
bourbon1795 2010-04-05
  • 打赏
  • 举报
回复
复制 新建类库 粘贴代码 就生成 dll文件了 dll就是Dynamic Link Library 动态链接库
polarissky 2010-04-05
  • 打赏
  • 举报
回复
打开Visual Studio 2008,“文件”-》“新建”-》“项目”-》“Visual C#”-》“类库”,选择位置,“确定”,IDE会自动生成一个名为Class1.cs的文件,你把你的代码贴进去,添加对System.Web的引用,改改CS文件的名字,就可以了,“生成”-》“生成解决方案”,就会在bin文件夹下生成DLL文件
xiaoxiaoxiao8 2010-04-05
  • 打赏
  • 举报
回复
怎么直接生成。把这代码放到什么地方。?
tologo 2010-04-05
  • 打赏
  • 举报
回复
直接点生成文件就可以了,用的时候直接调用

62,241

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧