我有一段javascript代码,原本写在asp .net页面里,我想把它写入asp .net后台代码中。请问要怎么写?谢谢!
解决方案 »
- <input type="radio" name="radCategory" />
- ASP.NET的安全设置
- javascript如何能实现这样的功能呢??请进`````
- DetailsView顽固问题 自动生成的按钮都是英文
- 请教各位前辈一个Javascript的判断问题!!!
- 求教一个关于FORMS验证的问题(急切中...)
- 请问:WEB开发的GET 和 POST 方式 有什么区别
- 请问.dll怎么运行的?
- 一个既简单又纳闷的action问题.
- 求救!数据库字段中的NULL值
- asp.net futures ajax web site与ajax control toolkit web site这两个模板的区别
- 关于asp.net中使用jqery的$.ajax()回传问题
这样就可以,我一般是这么用的。
不过你得最好在加载页面前就加载。
别用着时面页上不有。
string strScript = "function OpenWin(){";
strScript += " var str=window.showModalDialog('../Default.aspx',window,'dialogWidth:300px;dialogHeight:280px;center:yes');";
strScript += "}";
ScriptManager.RegisterStartupScript(this.UpdatePanel1, this.GetType(), "clientScript", strScript, true);
然后你再出发这个按钮的click事件就行了
按钮名称.Attributes.Add("onclick", "javascript:OpenDetailWin()");
这样就可以了。
或者是("<script></script>")这样也可以加入
不过还得具体情况具体分析
2 Page.ClientScript.RegisterStartupScript(this.GetType(), "jsCode", "function aaa(){}", true);
这是不用updatepanel的:Response.Redirect("<script></script>");
<script type="text/javascript">
var ig=document.getElementById("obj");
var box=document.getElementById("box");
var btn=document.getElementById("btn");
var w=box.offsetWidth; //边框宽度,就是162px
var isIE = (document.all) ? true : false;
var isIE6 = isIE && ([/MSIE (\d)\.0/i.exec(navigator.userAgent)][0][1] == 6);
var Bind = function(object, fun) {
return function() {
return fun.apply(object, arguments);
}
}
ig.style.position ="fixed";
ig.style.zIndex='1000';
ig.style.left='0'+"px";
ig.style.top='100'+"px";
if(isIE6){
ig.style.position ="absolute";
ig._fixed = Bind(ig, function(){
ig.style.marginTop = document.documentElement.scrollTop + "px";
ig.style.marginLeft = document.documentElement.scrollLeft + "px";});
ig._fixed()
window.attachEvent("onscroll", ig._fixed); //当滚动时,保持相对位置
}
function set(){
if(ig.offsetLeft+w==0)
d(1);
else
d(-1);
}
function d(n){
var T=setTimeout("d("+n+")",1);
n=n<0?n-20:n+20
ig.style.left=ig.offsetLeft+n+"px";
if(ig.offsetLeft+w<=0){
clearTimeout(T);
ig.style.left=-w+"px";
document.getElementById("icon").src="../Image/z_menuClose.gif";
//btn.style.backgroundImage
//btn.style.background-image: url('file:///c:/inetpub/wwwroot/ITService/../Image/z_menuClose.gif');
// btn.style.backgroundColor="#0000FF"; //蓝色,关闭的时候
}
if(ig.offsetLeft>=0){
clearTimeout(T);
ig.style.left=0;
document.getElementById("icon").src="../Image/z_menuOpen.gif";
// btn.style.background-image: url('file:///c:/inetpub/wwwroot/ITService/../Image/z_menuOpen.gif');
// btn.style.backgroundColor="#FF0000"; //红色,打开的时候
}
}
</script>