后台button onclick 事件 里如何调用JS方法。
protected void Btndowlod_Click(object sender, EventArgs e){
string dowid = Request.QueryString["room_id"];
string strSql = "SELECT room_url ,room_id FROM Roominfo where room_id ='" + dowid + "'";
SqlConnection conn;
SqlCommand comm;
SqlDataAdapter data;
DataTable table;
conn = new SqlConnection(strConn);
try
{
conn.Open();
comm = new SqlCommand(strSql, conn);
data = new SqlDataAdapter();
table = new DataTable();
data.SelectCommand = comm;
data.Fill(table);
string dowurl = table.Rows[0]["room_url"].ToString();
Session["dowurl"] = dowurl;
}
catch
{
Response.Write("<script language=javascript>alert('系统异常,请联系管理员');</script>");
}
finally
{
conn.Close();
}
}
<SCRIPT LANGUAGE="JavaScript">
function PassParameter()
{
if (Session["dowurl"] != " " )
{
WebPlugin1.Param = Session["dowurl"] ;
WebPlugin1.GetParam() ;
}
}
</SCRIPT>
请问在Btndowlod_Click 事件里如何调用JS PassParameter()
--------------------编程问答-------------------- http://topic.csdn.net/u/20090519/09/c14682c9-b3ec-45f7-a1bb-86872e28f942.html --------------------编程问答-------------------- Response.Write(" <script language=javascript>alert('系统异常,请联系管理员'); </script>");
你不是有了吗?这样应该可行
--------------------编程问答--------------------
protected string jsStr;
PageLoad()
{
}
protected void Btndowlod_Click(object sender, EventArgs e)
{
if(1==1)
{
jsStr="<script>alert('1 == 1');</script>";
}
else
{
jsStr="<script>alert('1 != 1');</script>";
}
}
前台:
<html>
<body>
<form>
</form>
<%=jsStr%>
</body>
--------------------编程问答-------------------- 參考 --------------------编程问答--------------------
--------------------编程问答-------------------- Response.Write(" <script language=javascript>alert('系统异常,请联系管理员'); </script>");
string dowurl = table.Rows[0]["room_url"].ToString();
Session["dowurl"] = dowurl;
Response.Write(" <script language=javascript>PassParameter();</script>");
已经调用了前台的JS方法了 --------------------编程问答-------------------- RegisterStartupScript("", "js")</script>"); --------------------编程问答-------------------- protected void Btndowlod_Click(object sender, EventArgs e)
{
string dowid = Request.QueryString["room_id"];
string strSql = "SELECT room_url ,room_id FROM Roominfo where room_id ='" + dowid + "'";
SqlConnection conn;
SqlCommand comm;
SqlDataAdapter data;
DataTable table;
conn = new SqlConnection(strConn);
try
{
conn.Open();
comm = new SqlCommand(strSql, conn);
data = new SqlDataAdapter();
table = new DataTable();
data.SelectCommand = comm;
data.Fill(table);
string dowurl = table.Rows[0]["room_url"].ToString();
Session["dowurl"] = dowurl;
}
catch
{
///这里改成这样! 你那样输出有问题的!
string strScript="<script language=javascript>alert('系统异常,请联系管理员'); </script>"
ClientScript.RegisterStartupScript(Page.ClientScript.GetType(), "", strScript);
}
finally
{
conn.Close();
}
}
<SCRIPT LANGUAGE="JavaScript">
function PassParameter()
{
if (Session["dowurl"] != " " )
{
WebPlugin1.Param = Session["dowurl"] ;
WebPlugin1.GetParam() ;
}
}
</SCRIPT> --------------------编程问答-------------------- Response.Write(" <script language=javascript>alert('系统异常,请联系管理员'); </script>");
要是自定义的方法就在分号后面直接写上就可以了. --------------------编程问答-------------------- Response.Write(" <script language=javascript>PassParameter();</script>");
或者
Page.ClientScript.RegisterStartupScript(this.GetType(),"key","PassParameter();"); --------------------编程问答-------------------- Response.Write("<script language:javascript>方法名</script>"); --------------------编程问答-------------------- Response.Write(" <script language=javascript>javascrip方法 </script>"); --------------------编程问答-------------------- 该说的被人说了 --------------------编程问答-------------------- protected void Btndowlod_Click(object sender, EventArgs e)
{
string dowid = Request.QueryString["room_id"];
string strSql = "SELECT room_url ,room_id FROM Roominfo where room_id ='" + dowid + "'";
SqlConnection conn;
SqlCommand comm;
SqlDataAdapter data;
DataTable table;
conn = new SqlConnection(strConn);
try
{
conn.Open();
comm = new SqlCommand(strSql, conn);
data = new SqlDataAdapter();
table = new DataTable();
data.SelectCommand = comm;
data.Fill(table);
//调用前台PassParameter
string strScript=" <script language=javascript>PassParameter(); </script>"
ClientScript.RegisterStartupScript(Page.ClientScript.GetType(), "", strScript);
string dowurl = table.Rows[0]["room_url"].ToString();
Session["dowurl"] = dowurl;
}
catch
{
///这里改成这样! 你那样输出有问题的!
string strScript=" <script language=javascript>alert('系统异常,请联系管理员'); </script>"
ClientScript.RegisterStartupScript(Page.ClientScript.GetType(), "", strScript);
}
finally
{
conn.Close();
}
}
<SCRIPT LANGUAGE="JavaScript">
function PassParameter()
{
if (Session["dowurl"] != " " )
{
WebPlugin1.Param = Session["dowurl"] ;
WebPlugin1.GetParam() ;
}
}
</SCRIPT> --------------------编程问答-------------------- 问题继续中。谢谢LS所有朋友。 --------------------编程问答-------------------- 路过 --------------------编程问答-------------------- ls有你想要的答案 --------------------编程问答-------------------- 都试过了,没有正确的。 --------------------编程问答-------------------- botton 加 OnClientClick="js方法" --------------------编程问答-------------------- xcydj 如果那样做的法,click 事件就不运行了吧。 --------------------编程问答--------------------
............
protected void Btndowlod_Click(object sender, EventArgs e)
{
string dowid = Request.QueryString["room_id"];
string strSql = "SELECT room_url ,room_id FROM Roominfo where room_id ='" + dowid + "'";
SqlConnection conn;
SqlCommand comm;
SqlDataAdapter data;
DataTable table;
conn = new SqlConnection(strConn);
try
{
conn.Open();
comm = new SqlCommand(strSql, conn);
data = new SqlDataAdapter();
table = new DataTable();
data.SelectCommand = comm;
data.Fill(table);
string dowurl = table.Rows[0]["room_url"].ToString();
Session["dowurl"] = dowurl;
}
catch
{
///这里改成这样! 你那样输出有问题的!
string strScript=" <script language=javascript>alert('系统异常,请联系管理员'); </script>"
ClientScript.RegisterStartupScript(Page.ClientScript.GetType(), "", strScript);
}
finally
{
conn.Close();
}
//调用前台PassParameter
string strScript=" <script language=javascript>PassParameter(); </script>"
ClientScript.RegisterStartupScript(Page.ClientScript.GetType(), "", strScript);
}
<SCRIPT LANGUAGE="JavaScript">
function PassParameter()
{
if (Session["dowurl"] != " " )
{
WebPlugin1.Param = Session["dowurl"] ;
WebPlugin1.GetParam() ;
}
}
</SCRIPT>
你这样在试 ! 你要说还是错的! 你就别做.NET了!
--------------------编程问答-------------------- 拜托 OnClientClick="return js方法"
555555 --------------------编程问答--------------------
这种方法也可以!
我对LZ这样的人无言.......
--------------------编程问答--------------------
不过顺序有可能有问题! 应该是从后台给session写值! 然后在调用前台
如果按照上面的方法的话!就是先调用 JS了! 根据返回值才 调用后台! --------------------编程问答-------------------- 直接在js把值处理就完易做图
还要到处调
用个隐藏域存起吗 --------------------编程问答-------------------- 方法很多,嘿楼主开个枪撒。 --------------------编程问答-------------------- ClientScript.RegisterStartupScript(this.GetType(), "mess", "<script>PassParameter();</script>"); --------------------编程问答-------------------- 该说的都说了。 --------------------编程问答-------------------- 我决定不再进此贴。过分啊.... --------------------编程问答-------------------- this.btMyBike.Attributes.Add("onclick", "testMessageBox(event);");
补充:.NET技术 , ASP.NET