- //将层divLayerTK给显示出来
- string scriptBrowseTuiKuan = "<script>document.getElementById('divLayerTK').style.display =
- '';</script>";
- this.Page.ClientScript.RegisterStartupScript(this.GetType(), "MyBrowseTKAlert",
- scriptBrowseTuiKuan);
- //将层divLayerTK设为不显示
- string scriptCloseTuiKuan = "<script>document.getElementById('divLayerTK').style.display =
- 'none';</script>";
- this.Page.ClientScript.RegisterStartupScript(this.GetType(), "MyCloseTKAlert",
- scriptCloseTuiKuan);
- //页面代码
- <asp:ButtonField HeaderText="操作" CommandName="Assert" Text="商户维护"/>
- <asp:ButtonField HeaderText="删除" CommandName="deleteNow" Text="商户删除"/>
- //后台代码
- //当选中GridView中的行的以下事件被激发
- protected void MerChantTable_RowCommand(object sender, GridViewCommandEventArgs e)
- {
- string index = e.CommandArgument.ToString();
- string id = this.MerChantTable.Rows[System.Convert.ToInt32(index)].Cells
- [0].Text;
- this.txHidden.Text = id;
- //当操作按钮被选中时
- if (e.CommandName.Equals("Assert"))
- {
- this.Response.Redirect("AssertMerChant.aspx?id=" + id);
- }
- //当删除按钮被选中时
- if (e.CommandName.Equals("deleteNow"))
- {
- string script = "<script>document.getElementById('divlogin').style.display =
- '';</script>";
- this.RegisterStartupScript("alert", script);
- }
- }
后台代码中判断页面中的层是否显示
本文介绍如何在 ASP.NET 中使用 C# 控制特定层的显示与隐藏状态,通过 GridView 的 RowCommand 事件处理来实现按钮操作,如商户维护与删除,并展示了具体的前后端交互代码。


被折叠的 条评论
为什么被折叠?



