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

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?bWFya203NQ==?=

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

    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 drawsubmitcomme nts

    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.redire ct.. i have to create a variable.. like say
    "Page varPage" and do a varPage.Respons e.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

  • =?Utf-8?B?bWFya203NQ==?=

    #2
    RE: dynamically generated web controls asp.net best method to access v



    "markm75" wrote:
    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 drawsubmitcomme nts
    >
    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.redire ct.. i have to create a variable.. like say
    "Page varPage" and do a varPage.Respons e.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?

    Comment

    Working...