Click here to Skip to main content
15,896,557 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a textbox in my user control and I am using this user control in all my aspx pages.
When I enter some value to the textbox and press enter button in keyboard, I want to perform some functions.

How can I get the ascx textbox value in my aspx page?
Posted
Updated 8-Nov-10 22:45pm
v3
Comments
Dalek Dave 9-Nov-10 4:45am    
Edited for Readability.

For that you need to handle usercontrol generated click event inside your individual page where you have resided usercontrol using deleage

For that THIS[^] Domestic article may be useful for you.

Please vote and Accept Answer if it Helped.
 
Share this answer
 
One of the ways I know of is to create a public property in your user control which would get and set the value of the textbox's text property.
 
Share this answer
 
Hi
you can access Textbox from user control like

C#
UserControl1 ucl = (UserControl1) MyUserControl;
TextBox txt = uc1.FindControl("txtUserName");


Updated Answer:

You can put Textbox inside the panel and set DefaultButton="btnSearch" to your button id
btnsearch is id of button

Please do let me know, if you have any doubt.

Please provide "Vote":thumbsup: if this would be helpful, and make "Accept Answer" if this would be correct answer.:rose:

Thanks,
Imdadhusen
 
Share this answer
 
v2
Comments
MathewPV 9-Nov-10 5:15am    
yes what you told is correct i got the value but i want to use content and when i press enter in keyboard some other operations like search should perform
Sunasara Imdadhusen 9-Nov-10 8:01am    
You can put Textbox inside the panel and set DefaultButton to your button id

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900