dynamically generated web controls asp.net best method to access v

M

markm75

I have a simple page i'm trying to do dynmaically.. i have a page called
submitcomments.aspx with the .cs codebehind..

before i created everything in design view.. now i've ripped that out and
added a asp panel to the page and created a procedure in my c# datalayer.cs
file called drawsubmitcomments

in that procedure i create the text boxes and buttons.



Problem is.. this code is not in the code behind for the page, so when i do
commands like response.redirect.. i have to create a variable.. like say
"Page varPage" and do a varPage.Response.redirect from the datalayer.cs
procedure (which im not even sure if it will work)..

I also had to create the click event, which now resides in that cs file as
well.. so on the click event i cant check the values for say txtBOX1.text
etc.. unless i made these text boxes "global variables" to the datalayer.cs..

I'm not sure what the best practice is for something like this.. should i
have done all the dynamic creation in the .cs codebehind file.. or make the
variables global over there.. or something else?

Thanks for any tips
 
M

markm75

markm75 said:
I have a simple page i'm trying to do dynmaically.. i have a page called
submitcomments.aspx with the .cs codebehind..

before i created everything in design view.. now i've ripped that out and
added a asp panel to the page and created a procedure in my c# datalayer.cs
file called drawsubmitcomments

in that procedure i create the text boxes and buttons.



Problem is.. this code is not in the code behind for the page, so when i do
commands like response.redirect.. i have to create a variable.. like say
"Page varPage" and do a varPage.Response.redirect from the datalayer.cs
procedure (which im not even sure if it will work)..

I also had to create the click event, which now resides in that cs file as
well.. so on the click event i cant check the values for say txtBOX1.text
etc.. unless i made these text boxes "global variables" to the datalayer.cs..

I'm not sure what the best practice is for something like this.. should i
have done all the dynamic creation in the .cs codebehind file.. or make the
variables global over there.. or something else?

Thanks for any tips



Also.. if i try to dynamically create requiredfield validators.. they cant
find the controls they are to check when the page loads.. any thoughts on
this one too?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top