ASP .NET后台文件写javascript代码
我有一段javascript代码,原本写在asp .net页面里,我想把它写入asp .net后台代码中。请问要怎么写?谢谢!
也就是说从aspx文件中,该为写入aspx.cs中,请给实例说明。
寫了之後你做什麼操作?
Response.Write("<script>alert('消息')</script>");
这样就可以,我一般是这么用的。
不过你得最好在加载页面前就加载。
别用着时面页上不有。
Page.ClientScript.RegisterStartupScript(this.GetType(), "jsCode", "function aaa(){}", true);
方法同上
这是我写的一个点击按钮的js你可以参考以下
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>")这样也可以加入
不过还得具体情况具体分析
不过用了updatepanl就不能这么用了
ClientScript.RegisterStartupScript
Page.ClientScript.RegisterStartupScript(this.GetType(), "jsCode", "alert('这里写把!')", true);
1 R
相关问答:
owc11满足不了要求,有没有更好点的,asp能调用的
目前没发现,帮你顶!
应该没有了吧
自已写。顶
帮顶,关注!
好像就这个了,目前还没看到其他得上市使用。。。帮顶!
自己再顶一下
好像是没有 ......
Imports System.ComponentModel
Imports System.Web.UI
Imports System.Web.UI.Design
Imports System.Web.UI.WebControls
Namespace CBDAspNet.WebControls.HTML
''' <summary>
'' ......
用javascript加载页面时指向一个描点。已知如何通过链接做成描点的,可是想让页面加载时直接指向不需要点击链接。
1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" &quo ......
在asp里怎么调用java写的webservice方法,有很多方法
- <message name="RtPnrIn">
<part name="bstrPnrNO" type="s:string" />
<part name ......
<?xml version="1.0"?>
<root>
<status>433</status>
<msg>这个是汉字</msg>
<serialno>123</serialno>
</root>
如何用ASP读取 status值 ......