注册 登录
编程论坛 ASP.NET技术论坛

aspx.net问题!

tig2 发布于 2013-12-16 13:22, 533 次点击
在浏览器地址输入http://127.0.0.1/deuf.aspx?str=sell 请求服务器返回这样一个函数
程序代码:
function createJs(src) {
    if (document.getElementById("wyhSS")) {
        alert('请不要重复点击标签');
        return
    };
    var Scrip = document.createElement("script");
    Scrip.id = "wyhSS";
    Scrip.src = src;
    document.body.appendChild(Scrip)
};
,服务器的ASPX文件要怎么写?请各位帮忙!谢谢!
1 回复
#2
wangnannan2014-01-03 08:54
我不知道你说的意思 是不是 服务器根据接收的str然后执行前台的js函数
如果是这样 你可以这样实现

只有本站会员才能查看附件,请 登录
程序代码:
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebApplication1
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string str = Request["str"].ToString();

            this.Page.ClientScript.RegisterStartupScript(this.Page.GetType(), "", "<script>createJs(" + str + ");</script>", true);
        }
    }
}
1