TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
pramod_pat1
NA
1
0
Calling Property and method of a user control from another user control
Dec 20 2006 10:38 PM
I have Created a property "SetExContent" and a method populateScreen()
in UserControl2.ascx.cs
private string setExContent;
public string SetExContent
{
get
{
return setExContent;
}
set
{
setExContent = value;
}
}
public void populateScreen()
{
string totContent = SetExContent;
//Populate all the fields of Usercontrol2 from totContent.
}
In User Contol1 I have
<asp:HiddenField ID="testhid" EnableViewState="true" runat="server" />
<asp:Button ID="Button2" runat="server" OnClientClick="document.all('testhid').v
alue = window.clipboardData.getData('Text')" OnClick="Button2_Click" Text="Paste & Populate UI" />
In userControl1.cs button click I want to set the property of SetExContent user control2 and call the metod populate screen.
void button2_click
{
usercontrol1.SetExContent = testhid.value; //Set user control2 property
populateScreen(); //Call user control2 method
}
How do I call user control2 property and method on user control1 button click.Pls provide the code.
----------------------------------------
----------
----
For your Info--
The two user controls are getting loaded in a page pagemail.aspx which has a code like this
------------------------
private string userControl1Path = "UserControls/userControl1.ascx";
private string userControl2Path = "UserControls/usercontrol2.ascx";
UserControls.UserControl1 userControl1;
UserControls.UserControl2 userControl1;
userControl1 = this.Page.LoadControl(this.userControl1P
ath) as UserControls.UserControl1;
this.controlHolder.Controls.Add(UserCont
rol1);
userControl2 = this.Page.LoadControl(this.userControl2P
ath) as UserControls.UserControl2;
this.controlHolder.Controls.Add(UserCont
rol2);
------------------------------
Reply
Answers (
0
)
Using ObjectDataSource to populate a DropDownField
Button Click event