webform传值

单页面传值:

<input type="button" class="shanchu" data-id="<%#Eval("ids") %>" data-name="<%#Eval("name") %>"   value="删除" />    --设置属性

var shanchu = document.getElementsByClassName("shanchu");
ids = 0;
for (x = 0; x < shanchu.length; x++) {
shanchu[x].onclick = function () {
document.getElementsByClassName("pan")[0].removeAttribute("hidden");
document.getElementsByClassName("pan1")[0].innerHTML = "确定要删除【" + this.getAttribute("data-name") + "】吗?";   --取属性的值
ids = this.getAttribute("data-id");              --取属性的值
}
}

document.getElementsByClassName("queding")[0].onclick = function () {
window.location.href = "delete.aspx?id=" + ids;
}

document.getElementsByClassName("quxiao")[0].onclick = function () {
document.getElementsByClassName("pan")[0].setAttribute("hidden", "hidden");
}

-------------------

跨页面传值:

前端html中:href="Default.aspx?id=<%#Eval("ids")%>"       

前端JS中:Window.location.href="Default.aspx?id=ids"  ;

后台C#中:Response.write("<script>window.location.href="Default.aspx?id=ids"  </script>");

后台C#中:Response.Redirect("Default.aspx");

后台C#中:Literal.Text="<script>window.location.href="Default.aspx?id=ids"  </script>";

取值:

Request["id"];   整个页面部分都能取到

 

posted on 2017-12-19 08:55  段了的弦  阅读(148)  评论(0编辑  收藏  举报