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()
{
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()
你不是有了吗?这样应该可行
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>
Session["dowurl"] = dowurl;
Response.Write(" <script language=javascript>PassParameter();</script>");
{
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>
要是自定义的方法就在分号后面直接写上就可以了.
或者
Page.ClientScript.RegisterStartupScript(this.GetType(),"key","PassParameter();");
{
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>
............
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了!
555555
不过顺序有可能有问题! 应该是从后台给session写值! 然后在调用前台
如果按照上面的方法的话!就是先调用 JS了! 根据返回值才 调用后台!