By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,117 Members | 2,178 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,117 IT Pros & Developers. It's quick & easy.

Passing data to a usercontrol before rendering?

P: n/a
Hi all, is it possible to update a usercontrol before it is rendered?

In my scenario I have a Page with a usercontrol on it. When a button is
clicked on the Page, I want to update the usercontrol, more specifically
making a placeholder become visible. However it wont work. Im confused. I
catch the button click even on the page and within this i run a method on my
usercontrol, however it doesnt seem to work. Few code lines given below.

Please help! Thank you!

In my PageI have something like this:

private void ButtonPatientSearch_Click(object sender, System.EventArgs e)
{
// construct dynamic search results
MyUserControl.ShowResults(ArrayListofObjects);
}

and in the user conrtol I have the method to catch this request

public void ShowResults(ArrayList ArrayListofObjects)
{
MyPlaceHolder.Visible = true;
Repeater1.DataSource = ArrayListofObjects;
Repeater1.DataBind();
}
Feb 12 '06 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Hi Tarun,

You should get the usercontrol reference first:

MyUserControl myUserControlObj =
(MyUserControl)Page.FindControl(MyUserControl_ID);
myUserControlObj.ShowResults(ArrayListofObjects);
HTH

Elton Wang

"Tarun Mistry" wrote:
Hi all, is it possible to update a usercontrol before it is rendered?

In my scenario I have a Page with a usercontrol on it. When a button is
clicked on the Page, I want to update the usercontrol, more specifically
making a placeholder become visible. However it wont work. Im confused. I
catch the button click even on the page and within this i run a method on my
usercontrol, however it doesnt seem to work. Few code lines given below.

Please help! Thank you!

In my PageI have something like this:

private void ButtonPatientSearch_Click(object sender, System.EventArgs e)
{
// construct dynamic search results
MyUserControl.ShowResults(ArrayListofObjects);
}

and in the user conrtol I have the method to catch this request

public void ShowResults(ArrayList ArrayListofObjects)
{
MyPlaceHolder.Visible = true;
Repeater1.DataSource = ArrayListofObjects;
Repeater1.DataBind();
}

Feb 12 '06 #2

P: n/a
Hi, thanks for the reply. The UC is already loaded on screen, it is not
dynamic.

I have the following code in my Page class

protected MyUserControl MyUserControlObject;

It is referencing it correctly, however I just cant get the UC to update or
rerender.

FYI to clarify, im trying to get my UC to update when a button is clicked on
the Page, however by the time the button click event is fired, i think my UC
has been rendered :(

Please help.
Thanks

Taz
"Elton W" <El****@discussions.microsoft.com> wrote in message
news:9C**********************************@microsof t.com...
Hi Tarun,

You should get the usercontrol reference first:

MyUserControl myUserControlObj =
(MyUserControl)Page.FindControl(MyUserControl_ID);
myUserControlObj.ShowResults(ArrayListofObjects);
HTH

Elton Wang

"Tarun Mistry" wrote:
Hi all, is it possible to update a usercontrol before it is rendered?

In my scenario I have a Page with a usercontrol on it. When a button is
clicked on the Page, I want to update the usercontrol, more specifically
making a placeholder become visible. However it wont work. Im confused. I
catch the button click even on the page and within this i run a method on
my
usercontrol, however it doesnt seem to work. Few code lines given below.

Please help! Thank you!

In my PageI have something like this:

private void ButtonPatientSearch_Click(object sender, System.EventArgs e)
{
// construct dynamic search results
MyUserControl.ShowResults(ArrayListofObjects);
}

and in the user conrtol I have the method to catch this request

public void ShowResults(ArrayList ArrayListofObjects)
{
MyPlaceHolder.Visible = true;
Repeater1.DataSource = ArrayListofObjects;
Repeater1.DataBind();
}

Feb 12 '06 #3

P: n/a
You have created the function but have you wired a handler for the event ?

--
Terry Burns
http://TrainingOn.net

"Tarun Mistry" <no****@nospam.com> wrote in message
news:%2******************@TK2MSFTNGP09.phx.gbl...
Hi, thanks for the reply. The UC is already loaded on screen, it is not
dynamic.

I have the following code in my Page class

protected MyUserControl MyUserControlObject;

It is referencing it correctly, however I just cant get the UC to update
or rerender.

FYI to clarify, im trying to get my UC to update when a button is clicked
on the Page, however by the time the button click event is fired, i think
my UC has been rendered :(

Please help.
Thanks

Taz
"Elton W" <El****@discussions.microsoft.com> wrote in message
news:9C**********************************@microsof t.com...
Hi Tarun,

You should get the usercontrol reference first:

MyUserControl myUserControlObj =
(MyUserControl)Page.FindControl(MyUserControl_ID);
myUserControlObj.ShowResults(ArrayListofObjects);
HTH

Elton Wang

"Tarun Mistry" wrote:
Hi all, is it possible to update a usercontrol before it is rendered?

In my scenario I have a Page with a usercontrol on it. When a button is
clicked on the Page, I want to update the usercontrol, more specifically
making a placeholder become visible. However it wont work. Im confused.
I
catch the button click even on the page and within this i run a method
on my
usercontrol, however it doesnt seem to work. Few code lines given below.

Please help! Thank you!

In my PageI have something like this:

private void ButtonPatientSearch_Click(object sender, System.EventArgs
e)
{
// construct dynamic search results
MyUserControl.ShowResults(ArrayListofObjects);
}

and in the user conrtol I have the method to catch this request

public void ShowResults(ArrayList ArrayListofObjects)
{
MyPlaceHolder.Visible = true;
Repeater1.DataSource = ArrayListofObjects;
Repeater1.DataBind();
}


Feb 12 '06 #4

P: n/a
> You have created the function but have you wired a handler for the event ?

--
Terry Burns
http://TrainingOn.net


This was indeed the problem! There i was trying to figure out how to se the
onPreRender events lol.

Stupid mistake!

Many thanks,
Kind Regards
Taz
Feb 12 '06 #5

P: n/a
No worries, glad to be of assistance

--
Terry Burns
http://TrainingOn.net

"Tarun Mistry" <no****@nospam.com> wrote in message
news:u9**************@TK2MSFTNGP11.phx.gbl...
You have created the function but have you wired a handler for the event
?

--
Terry Burns
http://TrainingOn.net


This was indeed the problem! There i was trying to figure out how to se
the onPreRender events lol.

Stupid mistake!

Many thanks,
Kind Regards
Taz

Feb 12 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.