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()   

解决方案 »

  1.   

    http://topic.csdn.net/u/20090519/09/c14682c9-b3ec-45f7-a1bb-86872e28f942.html 
      

  2.   

     Response.Write(" <script  language=javascript>alert('系统异常,请联系管理员'); </script>"); 
    你不是有了吗?这样应该可行
      

  3.   


     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>
      

  4.   

    string dowurl = table.Rows[0]["room_url"].ToString(); 
    Session["dowurl"] = dowurl; 
    Response.Write(" <script  language=javascript>PassParameter();</script>"); 
      

  5.   

    Response.Write(" <script  language=javascript>alert('系统异常,请联系管理员'); </script>"); 已经调用了前台的JS方法了
      

  6.   

    RegisterStartupScript("", "js")</script>");
      

  7.   

    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> 
      

  8.   

    Response.Write(" <script  language=javascript>alert('系统异常,请联系管理员'); </script>"); 
    要是自定义的方法就在分号后面直接写上就可以了.
      

  9.   

    Response.Write(" <script  language=javascript>PassParameter();</script>"); 
    或者
     Page.ClientScript.RegisterStartupScript(this.GetType(),"key","PassParameter();");
      

  10.   

    Response.Write("<script language:javascript>方法名</script>"); 
      

  11.   

    Response.Write(" <script  language=javascript>javascrip方法 </script>"); 
      

  12.   

    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> 
      

  13.   

    botton 加 OnClientClick="js方法"
      

  14.   

    xcydj 如果那样做的法,click 事件就不运行了吧。
      

  15.   


    ............
    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了!
         
      

  16.   

    拜托 OnClientClick="return js方法"
    555555
      

  17.   


     不过顺序有可能有问题! 应该是从后台给session写值! 然后在调用前台
      如果按照上面的方法的话!就是先调用 JS了! 根据返回值才 调用后台!
      

  18.   

            ClientScript.RegisterStartupScript(this.GetType(), "mess", "<script>PassParameter();</script>");
      

  19.   

    this.btMyBike.Attributes.Add("onclick", "testMessageBox(event);");