您的位置:首页 > Web前端 > JavaScript

js调用服务器控件cs中的方法(-)

2017-08-10 14:33 183 查看
页面:

 <input type="button"  class="SubmitAdv" onclick="AddApply()" value="提交" />

cs:

 protected void Page_Load(object sender, EventArgs e)

    {

if (Request.Form["SelectApi"] != null)

            {

                string result = "";

                switch (Request.Form["SelectApi"])

                {

                    case "Submit":

                        result = GetInfo();

                        break;

                    case "ApplyList":

                        result = ApplyList();

                        break;

                    default: break;

                }

                Response.Clear();

                Response.Write(result);

                Response.End();

            }

}

js:

    function AddApply() {     

        $.ajax({

            type: "POST",

            url: "xxxx.aspx",

            async: true,

            data: { SelectApi: "Submit" },

            dataType: "text",

            success: function (result) {

                alert(result);

            }

        });

    }


内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息