前台:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm2.aspx.cs" Inherits="WebApp.positionManagement.WebForm2" %>后台:using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;namespace WebApp.positionManagement
{
public partial class WebForm2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
bindhtml();
}
public void bindhtml()
{
Response.Write("<html>");
Response.Write("<head>");
Response.Write("<title>测试</title>");
Response.Write("<script type=\"text/javascript\">");
Response.Write("function cheshi(){");
Response.Write("alert(\"进入1\");");
Response.Write("document.form1.action=\"Button1_Click\";");
Response.Write("document.form1.submit();");
Response.Write("alert(\"进入2\");");
Response.Write("}");
Response.Write("</script>");
Response.Write("</head>");
Response.Write("<body>");
string path = HttpContext.Current.Server.MapPath("~/positionManagement/WebForm2.aspx");
Response.Write(path);
Response.Write("<form name=\"form1\" action=\"" + path + "\" id=\"form1\">");
Response.Write("<div>");
Response.Write("<input id=\"btnAdd\" type=\"button\" value=\"确定\" onclick=\"return cheshi()\" />");
Response.Write("</div>");
Response.Write("<form>");
Response.Write("<from>");
Response.Write("</body>");
Response.Write("</html>");
}
public void Button1_Click(object sender, EventArgs e)
{
Response.Write("<script>alert('测试成功!');</script>");
}
}
}
老是报个找不到路径?怎么解决呢?
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm2.aspx.cs" Inherits="WebApp.positionManagement.WebForm2" %>后台:using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;namespace WebApp.positionManagement
{
public partial class WebForm2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
bindhtml();
}
public void bindhtml()
{
Response.Write("<html>");
Response.Write("<head>");
Response.Write("<title>测试</title>");
Response.Write("<script type=\"text/javascript\">");
Response.Write("function cheshi(){");
Response.Write("alert(\"进入1\");");
Response.Write("document.form1.action=\"Button1_Click\";");
Response.Write("document.form1.submit();");
Response.Write("alert(\"进入2\");");
Response.Write("}");
Response.Write("</script>");
Response.Write("</head>");
Response.Write("<body>");
string path = HttpContext.Current.Server.MapPath("~/positionManagement/WebForm2.aspx");
Response.Write(path);
Response.Write("<form name=\"form1\" action=\"" + path + "\" id=\"form1\">");
Response.Write("<div>");
Response.Write("<input id=\"btnAdd\" type=\"button\" value=\"确定\" onclick=\"return cheshi()\" />");
Response.Write("</div>");
Response.Write("<form>");
Response.Write("<from>");
Response.Write("</body>");
Response.Write("</html>");
}
public void Button1_Click(object sender, EventArgs e)
{
Response.Write("<script>alert('测试成功!');</script>");
}
}
}
老是报个找不到路径?怎么解决呢?
解决方案 »
- GridView在翻页的时候会有闪动。。。
- 急等。。。LinkButton出现错误:不允许用于访问路径"/courses/java.pdf"的HTTP 谓词 POST
- 调试时怎么进不了调用的模态窗体
- A.aspx中包含Datagrid.ascx控件,为什么Datagrid_SortCommand事件不执行,小妹急须帮助
- 关于验证控件的问题!高手请进!
- 如何将Button控件Render成这样的<input ...................../>,符合XML标准的控件,具体入内看
- 关于页面的问题!在线等候!
- 新手问题
- 我想在XML文件的某个节点下添加一个子节点,并且给这个子节点添加一个属性,怎么做?
- 关于namespace的一个问题
- FreeTextBox问题
- 请教XML文件和模式关联验证的问题
在页面调用document.getElementById("").Click();
+++++++++++++++++第一种情况:
1.后台方法:
protected string CsharpVoid(string strCC)
{
return strCC;
}
2.javascript 调用
<script language="javascript">
var s = "<%=CsharpVoid("www.esoutong.com")%>";
document.write(s);
</script>
+++++++++++++++++第二种情况:
1.后代码:
protected void CsharpVoid()
{
string strCC = "www.esoutong.com";
Response.Write(strCC);
}
2.调用方法:CsharpVoid()
<script language="javascript">
document.write("<%CsharpVoid();%>");
</script>
Response.Write("document.form1.action=\"Button1_Click\";");
要改成
Response.Write("document.form1.action=~/positionManagement/WebForm2.aspx");
必须有当前路径文件!
Response.Write("document.form1.action=~/positionManagement/WebForm2.aspx");
以后,在Load里面处理请求,也就是写你的事件代码,可以起到执行的作用,但是页面会刷新。所以,还是建议用Ajax。