473,412 Members | 3,860 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,412 software developers and data experts.

How to clear a user control's controls

26
hi,
I have a user control registered on my parent page.parent page have a link of Add new employee when click on a link user control opened after save click it save all the information,when againly click on link it show previous information that was saved ..plz help me how to clear user control's all control
May 29 '09 #1
3 6607
PRR
750 Expert 512MB
Use Page.Findcontrol to get a reference to usercontrol and then use usercontrol .findcontrol to get access to usercontrol controls like textbox....
Another way would be define public method/properties in user control and clear the text...
May 29 '09 #2
maliksleo
115 100+
you can do it by just redirecting to the same page. It will refresh the page and reload it from the begining and all the previous data will not show again.
If you dont want to redirect your page then you will have to clear all the controls on save button's click event.
Or else show your code for better understanding and suggestion for a different solution.

maliksleo
May 29 '09 #3
Frinavale
9,735 Expert Mod 8TB
@Ria12
Implement a public method called "ResetEmployee" or "ClearEmployeeInfo" something in your user control. This method should "clear"/reset any information.

For example:
Expand|Select|Wrap|Line Numbers
  1. Public Sub ClearEmployeeInfo()
  2.   txt_firstName.Text = ""
  3.   txt_lastName.Text = ""
  4.   txt_employeeNumber.Text = ""
  5.   txt_phoneNumber.Text = ""
  6.   txt_address.Text = ""
  7. //.......
  8. End Sub
Since this method is Public you can call it from your main page code (say in your save button click):

Expand|Select|Wrap|Line Numbers
  1. Private Sub btn_Save_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btn_Save.Click
  2. //....save data
  3.    myUserControlInstance.ClearEmployeeInfo()
  4.  
  5. End Sub
May 29 '09 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Joe | last post by:
I'm wondering how to loop through controls in VB.NET. I have the code from VB6 ok, but I can't figure out how to do it correctly in .NET. This is an example from my VB6 code that loops through...
9
by: Peter Afonin | last post by:
Hello: I need to clear all textboxes on the webform after the data has been submitted. How can I do this in one step? I found a C# code: // get a reference to your form control Control frm...
7
by: Eduardo78 | last post by:
Hello everybody, I heard I could clear (or move spaces) to all controls at ones without having to call each one of them. If someone remembers how to do that, I will apreciate your help. My...
2
by: Mike | last post by:
Ok I'm having a problem with a listview. I have a listview on a WinForm called ProgramInformationFrm. I call this from from 2 other forms. One is ProgramSearch Frm, the other is OpenNCFrm. The...
0
by: =?Utf-8?B?TWljaGFlbA==?= | last post by:
Hello, I want to control my WebParts programmatically. I have it set up so I can load my WebParts from code. The user can move them around. But I want to clear what they have done the next time...
6
by: RP | last post by:
I want to clear all the Text Boxes on the Form. Is there any short method to avoid clearing them one by one.
0
by: asumal | last post by:
Hello I am new to ASP.NET. I am using CreateUserWizard control to register & create a user. I am using Membership API. I have a Cancel button on the second step of CreateUserWizard control...
5
by: karsagarwal | last post by:
I have a bounded form and after I click the button to update/save. THe fields are still there. Is there a way to clear off the fields in the bounded form. Thanks, SA Here's the code that I...
32
by: =?Utf-8?B?U2l2?= | last post by:
I have a form that I programmatically generate some check boxes and labels on. Later on when I want to draw the form with different data I want to clear the previously created items and then put...
5
aas4mis
by: aas4mis | last post by:
I haven't had much luck with specific controls, their properties and loops in the past. I thought I would share this tidbit of code, feel free to modify/modularize in any way to suit your needs. This...
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
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
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...
0
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...
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,...
0
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...

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.