473,685 Members | 3,034 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Control.Add or Item.Add

I am new to ASP.NET and am becoming frustrated.

I am able to add items to a drop-down list box (SELECT) and the items remain
across server calls. When I add controls to a DIV (or to the Form for that
matter) they are not retained. When I add HTML from the server using the
InnerHtml property of the DIV (a Generic Html control) the state is
maintained. What is the difference between InnerHtml += <img etc. > and
Controls.Add(ne w HtmlImage())? Why does one persist and the other not.

Thanks in advance.

David
Dec 18 '05 #1
2 5614
Hi David,

The HtmlGenericCont rol stores its InnerHtml in ViewState. This is why it
persists. When you add a Control to it, you are not persisting that Control
in any way. The next PostBack, it's not there, because it wasn't persisted,
and you didn't re-add it.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
You can lead a fish to a bicycle,
but it takes a very long time,
and the bicycle has to *want* to change.

"David" <Co*********@Ad sorptionProcess Modeling.com> wrote in message
news:c5ipf.4180 1$WH.1753@duker ead01...
I am new to ASP.NET and am becoming frustrated.

I am able to add items to a drop-down list box (SELECT) and the items
remain across server calls. When I add controls to a DIV (or to the Form
for that matter) they are not retained. When I add HTML from the server
using the InnerHtml property of the DIV (a Generic Html control) the state
is maintained. What is the difference between InnerHtml += <img etc. >
and Controls.Add(ne w HtmlImage())? Why does one persist and the other
not.

Thanks in advance.

David

Dec 18 '05 #2

"Kevin Spencer" <ke***@DIESPAMM ERSDIEtakempis. com> wrote in message
news:eQ******** ******@TK2MSFTN GP10.phx.gbl...
Hi David,

The HtmlGenericCont rol stores its InnerHtml in ViewState. This is why it
persists. When you add a Control to it, you are not persisting that
Control in any way. The next PostBack, it's not there, because it wasn't
persisted, and you didn't re-add it.
Thank you. But how can I get it to persist?

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
You can lead a fish to a bicycle,
but it takes a very long time,
and the bicycle has to *want* to change.

"David" <Co*********@Ad sorptionProcess Modeling.com> wrote in message
news:c5ipf.4180 1$WH.1753@duker ead01...
I am new to ASP.NET and am becoming frustrated.

I am able to add items to a drop-down list box (SELECT) and the items
remain across server calls. When I add controls to a DIV (or to the Form
for that matter) they are not retained. When I add HTML from the server
using the InnerHtml property of the DIV (a Generic Html control) the
state is maintained. What is the difference between InnerHtml += <img
etc. > and Controls.Add(ne w HtmlImage())? Why does one persist and the
other not.

Thanks in advance.

David


Dec 19 '05 #3

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

Similar topics

4
1908
by: Ryan Ternier | last post by:
Hello, I have a repeater control that does the following on the ItemDataBound event. It works perfectly, except that when it prints out, the names of the controls aren't what I'd expect. lstYes.ID = "lstY" & drvTemp("UserID") 'Assuming ID is the part we want form the DB
3
3020
by: Shawn H. Mesiatowsky | last post by:
I have an array list that I want to display to the browser. I need very precise control of the repeater, so I have function for the OnItemDataBound event for the repater, then in that function I have my code to alter the displayed data. for instance, I need to display a button on the client side with client side script. I cannot accomplish this using the Button web control, so instead I use a label and in the text of the label I set it to...
7
5478
by: charliewest | last post by:
Hello - I'm using a Repeater control to render information in a very customized grid-like table. The Repeater control is binded to a DataSet with several records of information. Within the Repeater control, I've placed DropDownLists and CheckBoxes. When the user has updated the information, he/he clicks the submit button which is outside the scope of the Repeater control.
1
2635
by: keith.walter | last post by:
My first asp.net app is almost "done" and I am stuck. Here is my situation: I have a "mother" page add_customer.aspx and a"child" user control add_group.ascx. On the mother page is an "add group" button that makes the the panel inwhich the add_customer control resides VISIBLE=True. On the control, the user can edit the list of groups, or add a new one. After the edit is complete I want to make the panel again VISIBLE=False, as well as...
5
2101
by: Doug Handler | last post by:
Hi, I have a form (Form1) that contains a tab control which one tab has a customer user control (UserControl1). When the user double-clicks on the grid hosted there a new user control is created. I have a delegate / event that passes via EventArgs the appropriate info from the grid to the UserControl2. This works fine, except for now I'm a little lost on the final step....I need that once the UserControl2 is "filled out" that it is...
9
4687
by: Jaybuffet | last post by:
my aspx has something like this <asp:Repeater id="Repeater1" runat="server"> <ItemTemplate> <mycontrol:ctl id="ctlId" obj='<%# Container.DataItem %>' showItem="true"/> </ItemTemplate> /asp:Repeater> The DataSource for this Repeater is a CollectionBase of objects and is
2
16091
by: glenn | last post by:
Hi folks, I am trying to determine which item in a DropDownList Web control has been selected. I have posted an OnSelectedIndexChanged subroutine in my code with a reference to the subroutine in my asp tag as shown here: <asp:DropDownList id="ddlTo" runat="server"
8
3020
by: fernandezr | last post by:
I would like to use a user control as a template inside a repeater. Some of the fields in the control should be hidden depending on whether or not there is data. I'm still a ASP .Net newbie so the way I'm going about doing this might be a little off. I'd appreciate some help. Below is the code I have thus far but I'm not sure how to reference the user control within the foreach loop. <asp:Panel ID="pnlRosterProfile" runat="Server" />
14
14640
by: Rolf Welskes | last post by:
Hello, I have an ObjectDataSource which has as business-object a simple array of strings. No problem. I have an own (custom) control to which I give the DataSourceId and in the custom-control so I get the ObjectDataSource. No problem ..... ObjectDataSource src = .... //is ok i have it
1
1339
by: shapper | last post by:
Hello, I have a class where I created various controls. One of the controls have a property which is a generic list of WebControl. Then in web site page I have something like: Dim a As New MyNamespace.ListItem a.WebControls.Add(tbName) a.WebControls.Add(lLabel)
0
8569
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
8504
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8924
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
8758
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
7584
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
6431
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
5789
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2935
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2196
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.