473,769 Members | 3,383 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

postback find dynamic control problem

PCH
I have an c# asp.net (.net 1.1) web page, viewstate on.

The problem I am having is on the button click postback to update.

Heres the situation:

I have an asp table that has 1 header row.

On load I loop through a count, say 0 to 3, and dynamically build rows, into
the asp table.
For each row there are a few cells. for each cell there is/are a textbox
control(s), etc etc.

it builds great, everything works well for display.

When it posts back on a button click, I can no longer access those dynamic
controls.

I tried looping recursively through parent controls, but they dont exit,
they are lost on postback. The recursive loop finds every single control on
the page except those that I build dynamically and add to the ASP table
dynamically.

I also tried the request form object to look at each key. From that I can
find the control keys/values, EXCEPT for those controls I designated as
hidden, which i need!

Any ideas?

Thanks

Nov 18 '05 #1
5 2527
You are correct. The controls are gone after postback.
That's just how it works.
When you dynamically create controls, you are expected to dynamically create
them again upon postback.
It shouldn't be too hard if you design carefully. You should be able to
reuse the code that creates the controls in the first place.

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
"PCH" <pc***@hotmail. com> wrote in message
news:ux******** ******@tk2msftn gp13.phx.gbl...
I have an c# asp.net (.net 1.1) web page, viewstate on.

The problem I am having is on the button click postback to update.

Heres the situation:

I have an asp table that has 1 header row.

On load I loop through a count, say 0 to 3, and dynamically build rows,
into
the asp table.
For each row there are a few cells. for each cell there is/are a textbox
control(s), etc etc.

it builds great, everything works well for display.

When it posts back on a button click, I can no longer access those dynamic
controls.

I tried looping recursively through parent controls, but they dont exit,
they are lost on postback. The recursive loop finds every single control
on
the page except those that I build dynamically and add to the ASP table
dynamically.

I also tried the request form object to look at each key. From that I can
find the control keys/values, EXCEPT for those controls I designated as
hidden, which i need!

Any ideas?

Thanks

Nov 18 '05 #2
PCH
Greet.

So the only way to get the values is the request form object?

"Steve C. Orr [MVP, MCSD]" <St***@Orr.ne t> wrote in message
news:OJ******** ******@tk2msftn gp13.phx.gbl...
You are correct. The controls are gone after postback.
That's just how it works.
When you dynamically create controls, you are expected to dynamically create them again upon postback.
It shouldn't be too hard if you design carefully. You should be able to
reuse the code that creates the controls in the first place.

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
"PCH" <pc***@hotmail. com> wrote in message
news:ux******** ******@tk2msftn gp13.phx.gbl...
I have an c# asp.net (.net 1.1) web page, viewstate on.

The problem I am having is on the button click postback to update.

Heres the situation:

I have an asp table that has 1 header row.

On load I loop through a count, say 0 to 3, and dynamically build rows,
into
the asp table.
For each row there are a few cells. for each cell there is/are a textbox control(s), etc etc.

it builds great, everything works well for display.

When it posts back on a button click, I can no longer access those dynamic controls.

I tried looping recursively through parent controls, but they dont exit,
they are lost on postback. The recursive loop finds every single control on
the page except those that I build dynamically and add to the ASP table
dynamically.

I also tried the request form object to look at each key. From that I can find the control keys/values, EXCEPT for those controls I designated as
hidden, which i need!

Any ideas?

Thanks


Nov 18 '05 #3
No, recreate the controls on postback, but let ASP.NET fill in the user
selected values automatically.
Then you can examine the control values normally.

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
"PCH" <pc***@hotmail. com> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
Greet.

So the only way to get the values is the request form object?

"Steve C. Orr [MVP, MCSD]" <St***@Orr.ne t> wrote in message
news:OJ******** ******@tk2msftn gp13.phx.gbl...
You are correct. The controls are gone after postback.
That's just how it works.
When you dynamically create controls, you are expected to dynamically

create
them again upon postback.
It shouldn't be too hard if you design carefully. You should be able to
reuse the code that creates the controls in the first place.

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
"PCH" <pc***@hotmail. com> wrote in message
news:ux******** ******@tk2msftn gp13.phx.gbl...
>I have an c# asp.net (.net 1.1) web page, viewstate on.
>
> The problem I am having is on the button click postback to update.
>
> Heres the situation:
>
> I have an asp table that has 1 header row.
>
> On load I loop through a count, say 0 to 3, and dynamically build rows,
> into
> the asp table.
> For each row there are a few cells. for each cell there is/are a textbox > control(s), etc etc.
>
> it builds great, everything works well for display.
>
> When it posts back on a button click, I can no longer access those dynamic > controls.
>
> I tried looping recursively through parent controls, but they dont
> exit,
> they are lost on postback. The recursive loop finds every single control > on
> the page except those that I build dynamically and add to the ASP table
> dynamically.
>
> I also tried the request form object to look at each key. From that I can > find the control keys/values, EXCEPT for those controls I designated as
> hidden, which i need!
>
> Any ideas?
>
> Thanks
>
>
>



Nov 18 '05 #4
So that means you shouldn't create user controls for Items that use a
Database to retrieve values for it. I.e. you will end up accessing the
database on every postback?
Isn't this a major flaw for user controls?
Is there any around this?

"Steve C. Orr [MVP, MCSD]" <St***@Orr.ne t> wrote in message news:<OJ******* *******@tk2msft ngp13.phx.gbl>. ..
You are correct. The controls are gone after postback.
That's just how it works.
When you dynamically create controls, you are expected to dynamically create
them again upon postback.
It shouldn't be too hard if you design carefully. You should be able to
reuse the code that creates the controls in the first place.

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net

Nov 18 '05 #5
Ignore it does remember it.

re***@hotmail.c om (ree32) wrote in message news:<76******* *************** ****@posting.go ogle.com>...
So that means you shouldn't create user controls for Items that use a
Database to retrieve values for it. I.e. you will end up accessing the
database on every postback?
Isn't this a major flaw for user controls?
Is there any around this?

Nov 18 '05 #6

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

Similar topics

3
3890
by: Igor Belagorudsky | last post by:
Hi, i am trying to analyze data submitted in a form but the problem is that when i try to create the controls in code (which is what i want to do), it throws an obect not found exception on postback when i try to Page.FindControl: private void Page_Load(object sender, System.EventArgs e) { if (Page.IsPostBack) {
10
4514
by: Krista Lemieux | last post by:
I'm new to ASP.NET and I'm not use to the way things are handled with this technology. I've been told that when I have a control, I should only bind the data to it once, and not on each post back (basically have the data binding done in the If NOT IsPostBack Then statement). How come? How does this information get preserved? Which raises another question. Becuase I want to get away from the spaghetti code approach, I would like to create...
13
3674
by: Chris Thunell | last post by:
I have created several grids dynamically and have added them to different HTML placeholders on a vb.net web form. The grids and controls within them come up and view beautifully when the web page first starts, but when I click on a button, and the page comes back, my dynamically created grid and controls are not visible. Any thoughts? Please view my sample code below. If Not ispostback then creategrids end if
6
2042
by: Alan Silver | last post by:
Hello, I have a placeholder, which gets a user control added in when the page first loads. This user control contains a dropdownlist, and I would like to get hold of the value of this drop down list form the calling page on postback. Can I do this? If I try and use FindControl on the placeholder, it can't find the dropdownlist. I tried...
2
4832
by: Nemo | last post by:
Hi, I have i fishy problem when I have e Repeater with user controls. page_load { if (!isPostBack) { repeater.databind(); }
0
1537
by: Tony Hedge | last post by:
Okay I'm back with another issue ;-) Platform is .NET, VB 2005... I created a templace class that I was successfully able to add as a template column to a GridView control - dynamically!!! So my GridView has two 'hard-wired' columns plus any number of dynamic columns. And the template class has a checkbox control in it.
5
9549
by: vcuankitdotnet | last post by:
Hi. I have tried to search for this online, but can't find what I'm looking for so I decided to come here. I have a ASP.NET 2.0 website with a masterpage. My .aspx page uses the masterpage. Here is the HTML from my .aspx page: <asp:Content ID="Content" ContentPlaceHolderID="MyContentArea" runat="server"> <asp:PlaceHolder ID="phControlHolder" runat="server"></ asp:PlaceHolder><br /><br /> <asp:Button ID="btnSubmitForm" runat="server"...
2
1398
by: =?Utf-8?B?R2lkaQ==?= | last post by:
Hi, I'm new with ASP .NET, so i'm asking lots of questions latly... I've a web Page, with a button which i've created dynamicly and attached an Click event to it. as i understood here, i need to recreate the button again in the postback event. the problem is that i need this button, in a specific location (after i've
3
4373
balabaster
by: balabaster | last post by:
I've got a user control that builds a table of dynamic data based on a :LINQ class holding the data. The data is loaded using the LoadData(DataInstance) method. The table it builds contains a number of dynamic controls that themselves have postback/autopostback so the display of the control needs to be built at latest in the Page.Load event or the event handlers for the controls don't get wired up. Now if I have a page that uses this user...
0
9586
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10210
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10043
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9990
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9861
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8869
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7406
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5298
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3561
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.