Initialize an user control after it's loaded

  • Thread starter Thread starter Danny Ni
  • Start date Start date
D

Danny Ni

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