比如我要打开一个www.xxx.com/xxx.aspx,在地址中输入www.xxx.com/xxx.aspx即可,但是如果xxx.aspx中包含bb.js文件。如果我想打开xxx.aspx页面并且执行bb.js中的方法cc。怎么在地址栏中直接输入地址可以做到这样?
在php中看到好像这样即可www.xxx.com/xxx.php#cc()
但是在asp.net中如何做到?

解决方案 »

  1.   

    www.xxx.com/xxx.aspx?method=cc()Response.Write "<script>" + Request.QuerySTring["method"].ToString() + "</script>";
    ?
      

  2.   

    在cs文件定义个字段,将函数名传进去,在page——load中赋值,
    在aspx页面的body标签里定义事件onload=<%=cs里的变量%>。没试过,
      

  3.   


    cs:
    public string xxx = null;
        protected void Page_Load(object sender, EventArgs e)
        {
            xxx = Request.QueryString["funName"];
        }aspx:
     <script type="text/jscript">
        function lo(fun)
        {
            if(fun=="aa")
            aa();
            if(fun="bb")
            bb();
        }
        function bb()
        {
        }
        function aa()
        {
        }
        </script>
      

  4.   

    还有点:<body onload="lo(<%=xxx%>)">
      

  5.   

    这个可以
    aspx:
    <head runat="server">
        <title>无标题页</title>
        <script type="text/jscript">
        function lo(fun)
        {
            if(fun==="aaa")
            {aa();}
            if(fun==="bb")
            {bb();}
        }
        function bb()
        {
        alert("bb");
        }
        function aa()
        {
        alert("aa");
        }
        </script>
    </head>
    <body onload="lo('<%=qq%>')">
        <form id="form1" runat="server">
        <div>
        <asp:Label ID="la" runat=server></asp:Label>
        </div>
        </form>
    </body>
    cs: public string qq = null;
        protected void Page_Load(object sender, EventArgs e)
        {
            qq = Request.QueryString["funName"];
        }