Click here to Skip to main content
15,890,670 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,

i have ASCX page, and i need to retrieve the values of ascx in aspx page. but i dont know the id's of the controls in ascx page to use findcontrol method. please solve my problem, quick response appreciated.
Posted
Updated 3-Apr-12 21:01pm
v2

Hi,
Try using findcontrol(0)
 
Share this answer
 
Use properties
on ascx page
C#
public string textvalue
    {
        get
        {
            return TextBox1.Text;
        }
        set
        { 
         TextBox1.Text = value; 
        }
    }

and on aspx page
C#
string txtvalue=yourcontrol.textvalue;
 
Share this answer
 
Comments
Sanjeev Alamuri 4-Apr-12 3:04am    
yeah that's right, but the ASCX files provided by some other developer and i have no rights to edit those pages, so i have to find solution with in aspx page only, is there another way to get values...?
uspatel 4-Apr-12 3:08am    
If developer write this control to use controls of ascx page,then he/she also include properties or they provide id's of these controls to you.
If not, ask for the same...
Mastering Page-UserControl Communication[^]

or

//like this way to findout
 foreach (Control c in form1.Controls)
        {
            if (c.GetType ( ).Name.ToLower ( ) == "webusercontrol_ascx")
            {
                UserControl uc = (UserControl)c;

                txt = (TextBox)uc.FindControl ( "txtShip" );
            }
        }


Happy coding......
 
Share this answer
 
v2

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