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"]; 整个页面部分都能取到