I have a FormView on Default.aspx page. I have BLL_Census.cs class in App_Code folder. I want to set properties of textbox on FormView on Default page from BLL_Census.cs but don't know how to reference of find the FormView on the other page from within BLL_Census.cs.
Asked
Active
Viewed 620 times
0
-
So... what you need is to store the values somewhere and accessing them from another page? – Ivo May 15 '12 at 15:31
-
Not quite -- from a class in App_Code I want to change properties of a TextBox in Default.aspx page. – Eric3141 May 15 '12 at 17:03
-
During the same request? If so, how are you calling the method of that class from the page? could you post some code? – Ivo May 15 '12 at 21:04
-
It this is the case, this link may help you. It's for WinForms, but the same concepts apply: http://stackoverflow.com/questions/10576856/accessing-forms-control-from-another-class-c-sharp/10576875#10576875 – Ivo May 15 '12 at 21:05
-
ivowiblo: went to that link. Was able to get it to work for a button -- I changed the .Text property of the Button on the other page. However, I'm trying to change a property of a TextBox that is on a FormView. Don't know how to get my custom class BLL_Census.cs to see the TextBox1 on FormView1. I tried the following but it throws nullReference error -- likely because I am working with a new TextBox and not the one on the FormView1 itself. – Eric3141 May 16 '12 at 13:55
-
@ivowiblo
I'm actually trying to change a Label on FormView. public static void uspCensusInsert2(FormView frmvwCensus) { Label myLabel = (Label)frmvwCensus.FindControl("lblCensus"); myLabel.Text = "It worked!"; myLabel.Visible = true; } – Eric3141 May 16 '12 at 13:57
3 Answers
0
It will be easier if you place the value from BLL_census.cs into session variable and access it when other page is rendered in the browser

rt2800
- 3,045
- 2
- 19
- 26
-
I know how to use Session State to hold discrete values. But I want to set properties of a TextBox on another page. – Eric3141 May 15 '12 at 16:29
0
A page only "exists" when the browser call it So It's not possible to access another page from the current page. If you need to share page area, use Page Controls If you need to share data, use the Asp.NET Session

Fabske
- 2,106
- 18
- 33
-
I know how to use Session State to hold discrete values. But I want to set properties of a TextBox on another page. I don't know what Page Controls are or if this would help -- can you give me more info or point me to something? – Eric3141 May 15 '12 at 16:28
-
You store the value you want to set in the session, and in the other page you put code on the Page_Load to load this value from the session, and put it in the textbox. – Fabske May 15 '12 at 16:30
-
Oh... Yes, I thought of that approach. It's what I'm currently using -- if validation class in App_Code folder finds a problem then it returns strError string which contains the error then the calling page reveals a label and puts the error on the label. This is working. I also want to highlight the textbox that has the erroneous error but cannot directly set properties for the textbox from the class in App_Code. If I have to do it from Default.aspx.cs (the calling page) then it will become cluttered -- which is what I was tryign to avoid. – Eric3141 May 15 '12 at 16:56