468,284 Members | 1,573 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,284 developers. It's quick & easy.

Passing data to a usercontrol before rendering?

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
5 1153
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
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
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
> 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
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.

Similar topics

2 posts views Thread by Lars Pedersen | last post: by
2 posts views Thread by Dave Veeneman | last post: by
9 posts views Thread by Peter | last post: by
6 posts views Thread by Anonymous | last post: by
12 posts views Thread by Joe | last post: by
9 posts views Thread by Chris | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.