是这样的。别人给我一段代码:
叫我生产一个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了。步骤是怎么样。我要详细的步骤。
叫我生产一个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了。步骤是怎么样。我要详细的步骤。
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货