Click here to Skip to main content
15,899,025 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have a master page (MSTPAGE) in which have a User Control (USRCTL1) and User Control have a Label (lblamt) for current amount.

And In Content Page have a button(ADD) for Add Amount.

Add_ButtonClick()
{
???????????????????????
How to Change the Label Text of User Control
lblamt.Text = Convert.ToInt32(lblamt.Text) + 2;

}
Posted
Comments
Sergey Alexandrovich Kryukov 26-Sep-12 18:35pm    
?????????????? Does it look like a question. Remember, this is a Questions & Answers forum.
--SA
[no name] 26-Sep-12 19:14pm    
I know that this is a question. There is noting outsite of question.
Sergey Alexandrovich Kryukov 26-Sep-12 19:46pm    
Sure. There is nothing outside this comment.
--SA

1 solution

It is some thing like this as i do not know the details about your User Control

C#
Add_ButtonClick()
{
Object MyUserControl = this.Master.FindControl("UserControlID") as Object;

MyUserControl.lblamt.Text = Convert.ToInt32(MyUserControl.lblamt.Text) + 2;
 
} 
 
Share this answer
 
v2
Comments
[no name] 26-Sep-12 19:24pm    
Hi Thanks for reply,
The Label is in the User Control and User Control is in Master Page.
So pls update your answer.
MrLonely_2 26-Sep-12 19:30pm    
My answer is updated
[no name] 26-Sep-12 19:35pm    
only little change
Label MyLabel = this.Master.FindControl("USRCTL1").FindControl("lblamt") as Label;
MrLonely_2 26-Sep-12 19:41pm    
Is that work with you??
[no name] 26-Sep-12 19:46pm    
Yes

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