473,396 Members | 1,683 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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

Jun 27 '08 #1
1 1197


"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 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?

Jun 27 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Kiyomi | last post by:
Hello, I create a Table1 dynamically at run time, and at the same time, I would like to create LinkButton controls, also dynamically, and insert them into each line in my Table1. I would...
4
by: DotNetJunky | last post by:
I have built a control that runs an on-line help system. Depending on the category you selected via dropdownlist, it goes out and gets the child subcategories, and if there are any, adds a new...
4
by: Sandeep | last post by:
Hi I am doing one thing in my website ,actually i want to add controls dynamically to a web form and want to access the elements but when i postback the form,and access that control, it gives...
1
by: Kamal Jeet Singh | last post by:
Hi Friends !! I am facing problem in controlling the dynamically created controls on web page. The problem Scenario is Scenario:- My requirement is to load the web user controls on the web...
1
by: Reza Nabi | last post by:
Bakground: I have a webform (LoadCtl.aspx) which loads the user control to a placeholder dynamically based on the ctlName querystring passed in the URL. Webform (LoadCtl.aspx) also passes a...
6
by: Steve Booth | last post by:
I have a web form with a button and a placeholder, the button adds a user control to the placeholder (and removes any existing controls). The user control contains a single button. I have done all...
2
by: Vivek Sharma | last post by:
Hi There, I have a situation where I wish to load the controls dynamically on the basis of user role. Hence, I am using this code. if (UserRole == "IS Administrator") { Control UC1 =...
12
by: vbnewbie | last post by:
I am having problems accessing properties of dynamically generated objects in VB2005. Can someone please help? In a nutshell: My app creates an equal number of checkboxes and labels that share the...
4
by: Craig Buchanan | last post by:
I dynamically add data-bound templates to a gridview in my ascx control. while this works correctly when the gridview is databound to the datatable, i'm having issues on postback. i would like...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.