473,321 Members | 1,877 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,321 software developers and data experts.

Initialize an user control after it's loaded

Hi,
Is there a way to initialize an user control after it's loaded? I know this
is a strange question, so allow me to elaborate, I have an user control
which allow users to enter customer data and save them into SQL server. The
user control has about 50 textboxes and other web controls. To simplify,
let's say user control contains a textbox txtCompany and another textbox
called txtContact, for the first company, I entered "ABC plumbing" into
txtCompany , "Joe Smith" into txtContact. Then I tried to enter second
company, "ABC plumbing" and "Joe Smith" remain in the textboxes, I know
this is the way it is. Question is, is there a way to initialize the user
control after the first company is saved?

I know I can use codes to set txtCompany and txtContact to "", that's not
what I want. Cause I have over 100 user controls of this kind and each of
them has an average of 30-70 web controls, it's a lot of works to write an
initialize routine for every control.

TIA
Nov 18 '05 #1
3 1909
How about setting ViewState property to "False"

Regards,
Jignesh Desai.

"Danny Ni" <dn**@yahoo.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
Hi,
Is there a way to initialize an user control after it's loaded? I know this is a strange question, so allow me to elaborate, I have an user control
which allow users to enter customer data and save them into SQL server. The user control has about 50 textboxes and other web controls. To simplify,
let's say user control contains a textbox txtCompany and another textbox
called txtContact, for the first company, I entered "ABC plumbing" into
txtCompany , "Joe Smith" into txtContact. Then I tried to enter second
company, "ABC plumbing" and "Joe Smith" remain in the textboxes, I know
this is the way it is. Question is, is there a way to initialize the user
control after the first company is saved?

I know I can use codes to set txtCompany and txtContact to "", that's not
what I want. Cause I have over 100 user controls of this kind and each of
them has an average of 30-70 web controls, it's a lot of works to write an initialize routine for every control.

TIA

Nov 18 '05 #2
You can loop through the Controls property of the user control and
give all the child controls a default value.
See: http://odetocode.com/Articles/71.aspx

--
Scott
http://www.OdeToCode.com/blogs/scott/
On Mon, 29 Nov 2004 23:15:09 -0800, "Danny Ni" <dn**@yahoo.com> wrote:
Hi,
Is there a way to initialize an user control after it's loaded? I know this
is a strange question, so allow me to elaborate, I have an user control
which allow users to enter customer data and save them into SQL server. The
user control has about 50 textboxes and other web controls. To simplify,
let's say user control contains a textbox txtCompany and another textbox
called txtContact, for the first company, I entered "ABC plumbing" into
txtCompany , "Joe Smith" into txtContact. Then I tried to enter second
company, "ABC plumbing" and "Joe Smith" remain in the textboxes, I know
this is the way it is. Question is, is there a way to initialize the user
control after the first company is saved?

I know I can use codes to set txtCompany and txtContact to "", that's not
what I want. Cause I have over 100 user controls of this kind and each of
them has an average of 30-70 web controls, it's a lot of works to write an
initialize routine for every control.

TIA


Nov 18 '05 #3
This is more of a workaround, I guess. In my applications when I allow
users to save information, but remain on the page, I will usually send a
Response.Redirect( Request.RawUrl ). This will cause the whole page to
refresh and "reinitialize" all the field values.

It might not work for what you want. You might display a "saved
successfully" method and allowing them to enter a new one. When this
happens, I will save the message to Session and on page_load, check for the
Session variable, display the message, and remove it from Session.

HTH,

bill

"Danny Ni" <dn**@yahoo.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
Hi,
Is there a way to initialize an user control after it's loaded? I know this is a strange question, so allow me to elaborate, I have an user control
which allow users to enter customer data and save them into SQL server. The user control has about 50 textboxes and other web controls. To simplify,
let's say user control contains a textbox txtCompany and another textbox
called txtContact, for the first company, I entered "ABC plumbing" into
txtCompany , "Joe Smith" into txtContact. Then I tried to enter second
company, "ABC plumbing" and "Joe Smith" remain in the textboxes, I know
this is the way it is. Question is, is there a way to initialize the user
control after the first company is saved?

I know I can use codes to set txtCompany and txtContact to "", that's not
what I want. Cause I have over 100 user controls of this kind and each of
them has an average of 30-70 web controls, it's a lot of works to write an initialize routine for every control.

TIA

Nov 18 '05 #4

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

Similar topics

1
by: Josema | last post by:
Hi, Im starting to do the navigation of a portal, and for it, im using usercontrols.... Actually i have a user control in the top of the page that has some menus (contact, register, etc...) ...
7
by: Tim T | last post by:
Hi, I have the need to use dynamically loaded user controls in a webform page. I have the controls loading dynamically, and that part works fine. this is the code used in a webform to dynamically...
1
by: Earl Teigrob | last post by:
PROBLEM: When a user control is loaded into a PlaceHolder control more than once, the events do not fire on the first click of a control on the dynamically loaded user control. In other words, the...
1
by: Josh | last post by:
Hi Guys, I have been having a big problem with trying to pass parameters into a user control when the user control is dynamically loaded into a placholder. I am developing in c#. I have get...
3
by: Guadala Harry | last post by:
I have this scenario: ASPX Page dynamically loads userControl1 - which in turn dynamically loads userControl2. UserControl2 contains a TextBox Web Server control. When a user clicks a button in...
1
by: Robert Howells | last post by:
Perhaps I'm just too new at this to pull it off, or perhaps it's just bad architecture. I'd appreciate some feedback on the the wisdom (or lack thereof) in attempting the following: I'm not new...
3
by: Matej Kavčič | last post by:
Hello, i have one problem. I use loadcontrol in default.aspx page. On page i have placeholder and on load i with loadcontral load dynamic some user control. Some times i must load same user...
2
by: Diffident | last post by:
Hello All, I have a nested user control i.e., Control B which is loaded from Control A. Control A is itself dynamically loaded from a web form. Control A has a "Save" button which loads the...
5
by: Andrew Robinson | last post by:
I have a page that can load a number of different user controls. Each of these user controls inherits from a common base class and the controls are loaded based on application state, status, etc...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.