谁帮我写段代码,后台写JS,前台调用的? 最简单的ASPX.cs后台写个alert("a") 就行,还有前台aspx怎么调用,但IE首页察看源代码不会显示出来的。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 后台:Page.ClientScript.RegisterStartupScript(Page.GetType(), "", "function test(){alert('a');}", true);前台加一个Button点击调用:<input id="Button1" type="button" value="button" onclick="test()" /> protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Info", "function ShowMes(mes){alert(mes);}", true); } }<asp:Button runat="server" Text="Button" OnClientClick="ShowMes('hi');" />察看源代码不会显示出来的?放到js文件,然后再HTML中包含 Response.Write("<script>alert('a');</script>"); <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> <title>无标题页</title></head><body> <form id="form1" runat="server"> <div> <asp:Button ID="butBack" runat="server" Text="Button" /> <asp:Button ID="butGo" runat="server" Text="Button" onclick="butGo_Click" /> </div> </form></body></html>后台using System;public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { this.butBack.Attributes.Add("style","display:none"); } protected void butGo_Click(object sender, EventArgs e) { this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('a');document.getElementById('butBack').click()", true); }} 回车事件 如何获取DataList中的Repeater的复选框的值 求救!! 急 An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005 上传文件之后,读取文件内容的问题 搜索跳转问题 想找个兄弟应付下毕业设计 高分:如何让网页插件实现类似FlashGet那样的网页鼠标右键菜单多一个“用flashget下载”的选项? 如何在winform里嵌入ie? 怎么利用html的超链接打开一个无工具栏的新窗口? 无刷新按钮 怎么重构html控件
Page.ClientScript.RegisterStartupScript(Page.GetType(), "", "function test(){alert('a');}", true);前台加一个Button点击调用:
<input id="Button1" type="button" value="button" onclick="test()" />
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Info", "function ShowMes(mes){alert(mes);}", true);
}
}<asp:Button runat="server" Text="Button" OnClientClick="ShowMes('hi');" />察看源代码不会显示出来的?放到js文件,然后再HTML中包含
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>无标题页</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="butBack" runat="server" Text="Button" />
<asp:Button ID="butGo" runat="server" Text="Button" onclick="butGo_Click" />
</div>
</form>
</body>
</html>后台using System;public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
this.butBack.Attributes.Add("style","display:none");
}
protected void butGo_Click(object sender, EventArgs e)
{
this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('a');document.getElementById('butBack').click()", true);
}
}