string i=5;
Response.Write("<script>alert('"+i+"')</script>");

解决方案 »

  1.   

    这是我用vb写的一个程序,比较乱,
    你可以参考!!
    <%@ Import Namespace="System.Web.Security"%>
    <%@ Import Namespace="System.Data.OleDb"%>
    <%@ Import  Namespace="System.Data"%>
    <%@ Import Namespace="System.Configuration"%>
    <%@ Page language="vb" Codebehind="tree10.aspx.cs" AutoEventWireup="false" Inherits="denglu.tree10" %>
    <script language="vb" runat="server">
      Public FilePath,oraconn,UserID,Password as string
      sub Page_load (sender as object ,E as EventArgs)
      
      
      end sub
    </script>
    <html>
    <HEAD>
    <TITLE>New Document </TITLE>
    <META NAME="Generator" CONTENT="EditPlus">
    <META NAME="Author" CONTENT="">
    <META NAME="Keywords" CONTENT="">
    <META NAME="Description" CONTENT="">
    <script language="javascript" src="js/tree11.js"></script>
    <style type="text/css">
    <!--
    .skin0 

      position:absolute;
      width:200px;
      border:2px solid black; 
      background-color:menu; 
      font-family:Verdana; 
      line-height:20px; 
      cursor:default;
      visibility:hidden;
        }
      .skin1
      { 
        cursor: default; 
        font: menutext;
        font-size:9pt;
        position: absolute; 
        width: 100px; 
        background-color:menu;
        border: 1 solid buttonface; 
        visibility:hidden; 
        border: 2 outset buttonhighlight;
      }
    .menuitems 

      padding-left:15px;
      padding-right:10px; 
    }a:active {  font-size: 9pt; color: #000000; text-decoration: none}
    a:link {  font-size: 9pt; color: #000000;text-decoration: none}
    a:visited {  font-size: 9pt; color: #000000; text-decoration: none}
    a:hover {  font-size: 9pt; color: #000000; text-decoration: underline}
    --></style>
    <script language="javascript" src="js/youji.js"></script>
    <script language="vb" runat="server">
       dim node_id(200) as string,node_name(200) as string,node_parent(200) as String,node_url(200) As String ,node_window(200) As String ,node_width(200),node_height(200),node_left(200),node_top(200),node_target(200)
    </script>
    </HEAD>
    <BODY>
    <%
       
           
           FilePath=ConfigurationSettings.Appsettings("FilePath")
           oraconn=ConfigurationSettings.Appsettings("oraconn")
           UserID=ConfigurationSettings.Appsettings("UserID")
           Password=ConfigurationSettings.Appsettings("Password")
          ' response.write(FilePath)
           dim ip As string
           ip=ConfigurationSettings.AppSettings ("ip")
          ' Response.write(ip)
           dim left As integer,top 
            'Session("user_id")="020714124215"
           Session("menu_id")=menu_ids()
           if not zdymenu() or Session("biaoshi")="1" then
        
           dim orasession,conn,sql,rs,conn1,rs1,sql1
           if Session("biaoshi").Tostring()="1" then
           orasession=createobject("oracleinprocserver.xorasession")
               conn=orasession.dbopendatabase(oraconn,UserID+"/"+Password,0)
               sql="select M.name,M.url,M.module_id,M.parent_id,M.window,M.height,M.width,R.user_id,R.module_id,R.right from t_sys_modules M,t_sys_right_of_user R where R.user_id='"+Session("user_id")+"' and M.module_id=R.module_id and M.parent_id is null order by xh"
               rs=conn.createdynaset(sql,0)
               orasession=createobject("oracleinprocserver.xorasession")
               conn1=orasession.dbopendatabase(oraconn,UserID+"/"+Password,0)
               sql1="select M.name,M.url,M.module_id,M.parent_id,M.window,M.height,M.width,R.user_id,R.module_id,R.right from t_sys_modules M,t_sys_right_of_user R where R.user_id='"+Session("user_id")+"' and M.module_id=R.module_id order by xh"
               rs1=conn1.createdynaset(sql1,0)
               else
               
               orasession=createobject("oracleinprocserver.xorasession")
               conn=orasession.dbopendatabase(oraconn,UserID+"/"+Password,0)
               sql="select * from t_sys_modules where parent_id is null order by xh"
               rs=conn.createdynaset(sql,0)
               orasession=createobject("oracleinprocserver.xorasession")
               conn1=orasession.dbopendatabase(oraconn,UserID+"/"+Password,0)
               sql1="select * from t_sys_modules order by xh"
               rs1=conn1.createdynaset(sql1,0)
               end if
               
             
             dim i=0,module_id As string,right As string
             do while not rs1.eof 
             node_parent(i)=rs1("parent_id").value.toString()
             node_id(i)=rs1("module_id").value
             node_name(i)=rs1("name").value
             node_url(i)="http://www.163.com"
             'node_url(i)=rs1("url")
             node_window(i)=rs1("window").value.tostring()
             node_width(i)=rs1("width").value.tostring()
             node_height(i)=rs1("height").value
              module_id=rs1("module_id").value
              dim urll As String
              if Session("biaoshi")="1" then
              right=rs1("right").value.tostring()
              
              urll=FilePath+rs1("url").value+".aspx?ip="+ip+"&user_name="+Session("user_name")+"&module_id="+module_id+"&right="+right+"&name="+node_name(i)
              else
              urll=FilePath+rs1("url").value+".aspx?ip="+ip+"&user_name="+Session("user_name")+"&module_id="+module_id+"&name="+node_name(i)
            
              end if       
              if node_window(i)="new" then
                  if node_width(i)<>""then
                   
                  dim screen_w,screen_h
                  screen_w=Cint(Session("screen_w").tostring())
                  screen_h=Cint(session("screen_h").tostring())
                  left=(screen_w-rs1("width").value.tostring())/2
                  top=(screen_h-rs1("height").value.tostring())/2
                  end if
               
                 
             node_url(i)="javascript:void(window.open('"+urll+"','','width="+node_width(i)+",height="+node_height(i)+",left="+left.tostring()+",top="+top.tostring()+"'));"
          else
             node_url(i)=urll
             node_target(i)="main"
              end if
             
             i=i+1
             rs1.movenext
             loop
            
    Response.Write("<script language =javascript>")
      

  2.   

    序上:
    Response.Write ("var tree = new tree();")
    Response.Write ("var root = new root(1,'根目录','###','');")
    Response.Write ("tree.addRoot(root);")
    'Response.Write ("tree.addNode(new node(2,'生产数据上报系统',1,'folder','###',''));")
    do while not rs.eof 
      
    Response.Write ("var node1=new node('"+rs("module_id").value+"','"+rs("name").value+"',1,'folder','###','');")
    Response.Write ("tree.addNode(node1);")
      if ifparent(rs("module_id").value,rs1) then
       Response.Write ("tree.setNodeType(node1);")     
      end if
    Response.Write (writ(rs("module_id").value,rs,rs1))
         
    rs.movenext
    loop
    Response.Write ("tree.drawNodes(tree.root);")
    Response.Write ("</script>")
    rs1.close()
    rs1=nothing
    rs.close()
    rs=nothing 
    conn1.close()
    conn1=nothing
    conn.close()
    conn=nothing
        else
            dim orasession,conn,sql,rs,conn1,rs1,sql1,conn2,rs2
            dim right As string
            orasession=createobject("oracleinprocserver.xorasession")
                conn=orasession.dbopendatabase(oraconn,UserID+"/"+Password,0)
                sql="select a.item_id,a.parent_id,a.name,a.own,a.url as a_url,b.url as b_url,b.window,b.width,b.height,b.module_id from t_sys_user_menuitems a,t_sys_modules b where menu_id='"+Session("menu_id").value+"'and a.parent_id is null and a.module_id=b.module_id(+) order by a.xh desc"
                rs=conn.createdynaset(sql,0)
                orasession=createobject("oracleinprocserver.xorasession")
                conn1=orasession.dbopendatabase(oraconn,UserID+"/"+Password,0)
                sql1="select a.item_id,a.parent_id,a.name,a.own,a.url as a_url,b.url as b_url,b.window,b.width,b.height,b.module_id from t_sys_user_menuitems a,t_sys_modules b where menu_id='"+Session("menu_id").value+"' and a.module_id=b.module_id(+) order by a.xh desc"
                rs1=conn1.createdynaset(sql1,0)
                orasession=createobject("oracleinprocserver.xorasession")
                conn2=orasession.dbopendatabase(oraconn,UserID+"/"+Password,0)
                sql="select * from t_sys_right_of_user where user_id='"+Session("user_id")+"' and module_id='"+rs1("module_id").value.tostring()+"'"
                rs2=conn2.createdynaset(sql,0)
                if not rs2.bof then
                right=rs2("right").value.tostring()
                end if
                
            dim i=0,module_id As string,urll As string
            do while not rs1.eof 
               node_id(i)=rs1("item_id").value.tostring()
               node_name(i)=rs1("name").value.tostring()
               node_parent(i)=rs1("parent_id").value.tostring()
               node_window(i)=rs1("window").value.tostring()
                   node_width(i)=rs1("width").value.tostring()
                   node_height(i)=rs1("height")
                   module_id=rs1("module_id").value.tostring()
                   
                   urll=FilePath+rs1("url").value+".aspx?ip="+ip+"&user_name="+Session("user_name")+"&module_id="+module_id+"&right="+right+"&name="+node_name(i)
               if rs("own").value.tostring()="1" then
                 node_url(i)=rs1(4).value
               else
                  if node_window(i)="new" then
                   
                  if node_width(i)<>""then
                      dim screen_w,screen_h
                          screen_w=Cint(Session("screen_w").tostring())
                          screen_h=Cint(session("screen_h").tostring())
                          left=(screen_w-rs1("width").value.tostring())/2
                          top=(screen_h-rs1("height").value.tostring())/2
                      end if
                   
                    node_url(i)="javascript:void(window.open('"+urll+"','','width="+node_width(i)+",height="+node_height(i).value+",left="+left.tostring()+",top="+top.tostring()+"'));"
                  else
                   node_url(i)=urll
                   node_target(i)="main"
                  end if
              end if
               rs1.movenext
               i=i+1
            loop
            
            Response.Write("<script language =javascript>")
        Response.Write ("var tree = new tree();")
        Response.Write ("var root = new root(1,'根目录','###','');")
        Response.Write ("tree.addRoot(root);")
        'Response.Write ("tree.addNode(new node(2,'生产数据上报系统',1,'folder','###',''));")
        do while not rs.eof 
      
           Response.Write ("var Nodee=new node('"+rs("item_id").value.tostring()+"','"+rs("name").value.tostring()+"',1,'','###','');")
           Response.Write ("tree.addNode(Nodee);")
               if ifparent(rs("item_id").value.tostring(),rs1) then
              Response.Write ("tree.setNodeType(Nodee);")     
           end if
               Response.Write (writ(rs("item_id").value.tostring(),rs,rs1))
               rs.movenext
        loop
        Response.Write ("tree.drawNodes(tree.root);")
        Response.Write ("</script>")
        rs1.close()
        rs1=nothing
        rs.close()
        rs=nothing 
        conn1.close()
        conn1=nothing
        conn.close()
        conn=nothing 
        rs2.close()
        rs2=nothing
        conn2.close()
        conn2=nothing
    end if     
       
       
       
       
    %>
    <script language="vb" runat="server">
    function ifparent(fnode_id as string,rs1 as object) 
         dim i_j = 0
         do while i_j < rs1.RecordCount
          if node_parent(i_j) =fnode_id then
          ifparent=true
          exit function
          end if
          i_j = i_j + 1
         loop
          ifparent=false
       end function
        
    function writ(fnode_id,rs,rs1)

     dim i_i=0
     do while i_i< rs1.RecordCount 
      if node_parent(i_i)=fnode_id then
       Response.Write ("var Nodee=new node('"+node_id(i_i)+"','"+node_name(i_i)+"','"+fnode_id+"','','','"+node_target(i_i)+"');")
       if ifparent(node_id(i_i),rs1) then
        Response.Write ("tree.setNodeType(Nodee);")     
         Response.Write("tree.setNodeUrl(Nodee,'###');")
       else
       Response.Write ("tree.setNodeUrl(Nodee,"""+node_url(i_i)+""");")
       end if
       Response.Write ("tree.addNode(Nodee);")
       Response.Write (writ(node_id(i_i),rs,rs1))    
      end if
      i_i=i_i+1
     loop

    end function

    function zdymenu()
     dim oraSession,conn,sql,rs
     
     oraSession=createobject("oracleinprocserver.xorasession")
     conn=orasession.dbopendatabase(oraconn,UserID+"/"+Password,0)
     sql="select * from t_sys_user_menu where user_id='"+Session("user_id")+"'"
     rs=conn.createdynaset(sql,0)
        if rs.bof then
           zdymenu=false
           exit function
        else
           zdymenu=true
        end if

    end function

    function menu_ids()
        dim orasession,conn,sql,rs
       orasession=createobject("oracleinprocserver.xorasession")
       conn=orasession.dbopendatabase(oraconn,UserID+"/"+Password,0)
       sql="select * from t_sys_user_menu where user_id='"+Session("user_id")+"'"
       rs=conn.createdynaset(sql,0)
       if not rs.bof then
         menu_ids=rs("menu_id")
       end if
    end function </script>
    <!--[if IE]>
    <DIV class=skin0 id=ie5menu onmouseover=highlightie5() onclick=jumptoie5() 
    onmouseout=lowlightie5()>
    <div class="menuitems" url="zdy.aspx" target="_blank">自定义菜单</div>
    <div class="menuitems" url="moren.aspx" target="_blank">默认菜单</div>
    </div>
    <![endif]-->
    <script language="JavaScript">
             if (document.all&&window.print)
             {
                 if (menuskin==0)
                 { 
                  ie5menu.className="skin0";
                 }
                else
                {
                   ie5menu.className="skin1";
                   document.oncontextmenu=showmenuie5;
                   document.body.onclick=hidemenuie5;
                   
                }
            }
    </script>
    </BODY>
    </html>
      

  3.   

    ........// c#代码
    Response.Write("<script>javascript:window.open('打开页面?参数="+变量名+"</script>");