Click here to Skip to main content
15,890,438 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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


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

Dim chk As CheckBox = CType(A1.FindControl("chk"), 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


* 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!
Posted
Updated 23-Oct-18 6:37am
v2
Comments
j snooze 22-Oct-18 17:13pm    
Not sure I get the concept, you can't really show 2 web pages at once unless you are using frames, or its like a dialog page opened up. Or are you just trying to pass the check box value to the next page?
If its frames or a dialog you can use window.parent or window.opener in javascript to get at stuff. If its passing the value, you can use session variables, page posts, querystrings etc...
F-ES Sitecore 23-Oct-18 5:08am    
Pages only exist when they're being processed for a request (so the initial page load or a postback), and outside of that they don't exist so you can't access one page from another. If you want to use something from page a on page b you'll need to store what you need in a cookie so it can be accessed on page b, or if you are redirecting to page b from a postback, store the data you need from page a in the Session so you can access it from page b.

1 solution

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
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900