急求自定义控件 嵌入JS脚本问题 请高手解决!!!!!!!!! 在web页面中使用 file.js 文件中的脚本和使用style 文件一样,要在业面中先引用,这个文件 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 using System;using System.Collections.Generic;using System.ComponentModel;using System.Text;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;using System.Drawing;using System.Drawing.Design;namespace ASM.Web.WebControl.OneClickButton{ [DefaultProperty("Text")] [ToolboxData("<{0}:OneClickButton runat=server></{0}:OneClickButton>")] public class OneClickButton : Button { private string _ShowMsg; private string _Src; private int _Opacity; private Color _Color; [Bindable(true), Category("Show Message"), DefaultValue(""), Description("Show message on the page")] public string ShowMessage { get { return _ShowMsg; } set { _ShowMsg = value; } } [Bindable(true), Category("Show Message"), DefaultValue(""), Editor("System.Web.UI.Design.ImageUrlEditor", typeof(UITypeEditor)), Description("Image URL")] public string IMGSrc { get { return _Src; } set { _Src = value; } } [Bindable(true), Category("Show Message"), DefaultValue(""), TypeConverter(typeof(System.Web.UI.WebControls.WebColorConverter)), Description("Color")] public Color PageBackColor { get { if (_Color == Color.Empty) { _Color = Color.White; } return _Color; } set { if (value == Color.Empty) { value = Color.White; } _Color = value; } } [Bindable(true), Category("Show Message"), DefaultValue(""), Description("Opacity value between 0 ~ 100")] public int PageOpacity { get { try { int.Parse(_Opacity.ToString()); } catch { _Opacity = 50; } return _Opacity; } set { if (value < 0 || value > 100) { value = 50; } _Opacity = value; } } protected override void OnPreRender(System.EventArgs e) { string ImgUrl = ""; if (_Src != string.Empty) { if (_Src.StartsWith("~")) { ImgUrl = _Src.Remove(0, 2); } else { ImgUrl = _Src; } } else { ImgUrl = ""; } string color = ""; if (!_Color.IsEmpty) { if (_Color.IsNamedColor == false) { color = "#" + _Color.Name.Remove(0, 2); } else { color = _Color.Name; } } else { color = Color.White.Name; } Page.ClientScript.RegisterStartupScript(typeof(Page), "script", "<script>function CreateDiv(){" + "var div=document.createElement(\"<div id='div_show_d' style='position:absolute;visibility:visible;background:" + color + ";filter:alpha(opacity=" + _Opacity.ToString().Trim() + ");z-index:2;left:0;top:0;width:100%;height:100%;' onselectstart='return false' oncontextmenu='window.event.returnvalue=false'></div>\");" + "document.body.appendChild(div);" + "document.getElementById('div_show_d').innerHTML=\"<Table style='width:100%;height:100%;' oncontextmenu=return(false)><tr><td align='center' valign='middle'><img id='img1111' runat='server' src='load.gif' /><br/>" + ShowMessage + "</td></tr></Table>\";}</script>" +//" + ImgUrl + " "<script type=\"text/javascript\" language=\"javascript\" event=\"onclick\" for=\"" + base.ClientID + "\">" + "CreateDiv();</script>"); } }} 您的这个是用的script 连接串 但我的脚本比较大如果用连接串的话会带来很大的麻烦的所以我想直接吧JS文件嵌入到控件中去 但是总是无法执行脚本 正如我上面写的 不知道您是否能解决 .net发送url请求并且获取返回值 请教关于DATAGRID的模板列中CHECKBOX控件的问题 javascrip函数功能失效 如何从数据库中读出N条数据,然后写入缓存并绑定数据到DropDownList上?(高手请进) asp.net怎么知道用户已经关闭了浏览器,包括各种不正常的退出 怎么学asp.net快啊? aspx中的中文数据为何保存到数据库中变成"?" 学习asp.net 好 还是 学习jsp 那位高手能讲一讲reflection的用法,高分回报,多谢 各位高手,请问如果我装vs.net只想装vs.net和vb.net该装那几张碟 THML转txt 新手几个比较急得问题
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Drawing;
using System.Drawing.Design;namespace ASM.Web.WebControl.OneClickButton
{
[DefaultProperty("Text")]
[ToolboxData("<{0}:OneClickButton runat=server></{0}:OneClickButton>")]
public class OneClickButton : Button
{
private string _ShowMsg;
private string _Src;
private int _Opacity;
private Color _Color; [Bindable(true), Category("Show Message"), DefaultValue(""), Description("Show message on the page")]
public string ShowMessage
{
get
{
return _ShowMsg;
} set
{
_ShowMsg = value;
}
} [Bindable(true), Category("Show Message"), DefaultValue(""), Editor("System.Web.UI.Design.ImageUrlEditor", typeof(UITypeEditor)), Description("Image URL")]
public string IMGSrc
{
get
{
return _Src;
} set
{
_Src = value;
}
}
[Bindable(true), Category("Show Message"), DefaultValue(""), TypeConverter(typeof(System.Web.UI.WebControls.WebColorConverter)), Description("Color")]
public Color PageBackColor
{
get
{
if (_Color == Color.Empty)
{
_Color = Color.White;
}
return _Color;
} set
{
if (value == Color.Empty)
{
value = Color.White;
}
_Color = value; }
} [Bindable(true), Category("Show Message"), DefaultValue(""), Description("Opacity value between 0 ~ 100")]
public int PageOpacity
{
get
{
try
{
int.Parse(_Opacity.ToString());
}
catch
{
_Opacity = 50;
}
return _Opacity;
}
set
{
if (value < 0 || value > 100)
{
value = 50;
}
_Opacity = value;
}
} protected override void OnPreRender(System.EventArgs e)
{
string ImgUrl = "";
if (_Src != string.Empty)
{
if (_Src.StartsWith("~"))
{
ImgUrl = _Src.Remove(0, 2);
}
else
{
ImgUrl = _Src;
}
}
else
{
ImgUrl = "";
}
string color = "";
if (!_Color.IsEmpty)
{
if (_Color.IsNamedColor == false)
{
color = "#" + _Color.Name.Remove(0, 2);
}
else
{
color = _Color.Name;
}
}
else
{
color = Color.White.Name;
}
Page.ClientScript.RegisterStartupScript(typeof(Page), "script", "<script>function CreateDiv(){" +
"var div=document.createElement(\"<div id='div_show_d' style='position:absolute;visibility:visible;background:" + color + ";filter:alpha(opacity=" + _Opacity.ToString().Trim() + ");z-index:2;left:0;top:0;width:100%;height:100%;' onselectstart='return false' oncontextmenu='window.event.returnvalue=false'></div>\");" +
"document.body.appendChild(div);" +
"document.getElementById('div_show_d').innerHTML=\"<Table style='width:100%;height:100%;' oncontextmenu=return(false)><tr><td align='center' valign='middle'><img id='img1111' runat='server' src='load.gif' /><br/>" + ShowMessage + "</td></tr></Table>\";}</script>" +//" + ImgUrl + "
"<script type=\"text/javascript\" language=\"javascript\" event=\"onclick\" for=\"" + base.ClientID + "\">" +
"CreateDiv();</script>");
}
}
}
所以我想直接吧JS文件嵌入到控件中去 但是总是无法执行脚本 正如我上面写的 不知道您是否能解决