如何访问从一个页面到另一个页面的复选框。 [英] How to access a checkbox from one page to other.

查看:88
本文介绍了如何访问从一个页面到另一个页面的复选框。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在页面'A'中有一个CheckBox,我想访问'B'页面中的Checkbox。



我尝试了什么:



*我通过以下方式访问Page'B'页面'A' -

I have a CheckBox in page 'A' and I want to access that Checkbox in Page 'B'.

What I have tried:

* I'm accessing Page 'A' from Page 'B' by doing the following-

Protected WithEvents A1 As A





*我在Page_Load中声明了一个CheckBox如下:





* I've declared a CheckBox in the Page_Load as following:

Dim chk As CheckBox = CType(A1.FindControl("chk"), CheckBox)





*页面'B'有多个Case语句,我想在其中一个案例中访问CheckBox,我通过执行以下操作使CheckBox可见:





* Page 'B' has number of Case statements and I want to access that CheckBox in one of the Cases, and I'm making that CheckBox Visible by doing the following:

Case "9"

chk.Visible = True





*但是,它不是这样的。我只是希望CheckBox在Page'B'中可见。任何帮助将不胜感激。谢谢!



* But, It's not working that way. I just want the CheckBox to be Visible in Page 'B'. Any help would be greatly appreciated. Thanks!

推荐答案

对于ASP.NET WebForms,您可以使用以下任一方式访问上一页的控件:



Server.Transfer

跨页面PostBack

表格POST



一个例子:https://www.aspsnippets.com/Articles/Access-Previous-Page-controls-in-ASPNet-using- C-and-VBNet.aspx [ ^ ]



或者,您可以存储上一页的值,以便参考他们在另一页上使用:



使用公共属性

使用会话

QueryStrings
For ASP.NET WebForms, you can access controls from previous page using either:

Server.Transfer
Cross-Page PostBack
Form POST

An example: https://www.aspsnippets.com/Articles/Access-Previous-Page-controls-in-ASPNet-using-C-and-VBNet.aspx[^]

Alternatively, you can store the values of the previous page so you can reference them on the other page using:

Using Public Properties
Using Sessions
QueryStrings


这篇关于如何访问从一个页面到另一个页面的复选框。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆