473,796 Members | 2,697 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 ButtonPatientSe arch_Click(obje ct sender, System.EventArg s e)
{
// construct dynamic search results
MyUserControl.S howResults(Arra yListofObjects) ;
}

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

public void ShowResults(Arr ayList ArrayListofObje cts)
{
MyPlaceHolder.V isible = true;
Repeater1.DataS ource = ArrayListofObje cts;
Repeater1.DataB ind();
}
Feb 12 '06 #1
5 1294
Hi Tarun,

You should get the usercontrol reference first:

MyUserControl myUserControlOb j =
(MyUserControl) Page.FindContro l(MyUserControl _ID);
myUserControlOb j.ShowResults(A rrayListofObjec ts);
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 ButtonPatientSe arch_Click(obje ct sender, System.EventArg s e)
{
// construct dynamic search results
MyUserControl.S howResults(Arra yListofObjects) ;
}

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

public void ShowResults(Arr ayList ArrayListofObje cts)
{
MyPlaceHolder.V isible = true;
Repeater1.DataS ource = ArrayListofObje cts;
Repeater1.DataB ind();
}

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 MyUserControlOb ject;

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****@discuss ions.microsoft. com> wrote in message
news:9C******** *************** ***********@mic rosoft.com...
Hi Tarun,

You should get the usercontrol reference first:

MyUserControl myUserControlOb j =
(MyUserControl) Page.FindContro l(MyUserControl _ID);
myUserControlOb j.ShowResults(A rrayListofObjec ts);
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 ButtonPatientSe arch_Click(obje ct sender, System.EventArg s e)
{
// construct dynamic search results
MyUserControl.S howResults(Arra yListofObjects) ;
}

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

public void ShowResults(Arr ayList ArrayListofObje cts)
{
MyPlaceHolder.V isible = true;
Repeater1.DataS ource = ArrayListofObje cts;
Repeater1.DataB ind();
}

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******** **********@TK2M SFTNGP09.phx.gb l...
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 MyUserControlOb ject;

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****@discuss ions.microsoft. com> wrote in message
news:9C******** *************** ***********@mic rosoft.com...
Hi Tarun,

You should get the usercontrol reference first:

MyUserControl myUserControlOb j =
(MyUserControl) Page.FindContro l(MyUserControl _ID);
myUserControlOb j.ShowResults(A rrayListofObjec ts);
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 ButtonPatientSe arch_Click(obje ct sender, System.EventArg s
e)
{
// construct dynamic search results
MyUserControl.S howResults(Arra yListofObjects) ;
}

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

public void ShowResults(Arr ayList ArrayListofObje cts)
{
MyPlaceHolder.V isible = true;
Repeater1.DataS ource = ArrayListofObje cts;
Repeater1.DataB ind();
}


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******** ******@TK2MSFTN GP11.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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
9689
by: Lars Pedersen | last post by:
My app is adding a usercontrol at runtime. How is it possible to remove this usercontrol? Have tried Page.Controls.Remove(UserControl);, but that wont do the trick - any suggestions? -Lars
2
7124
by: Dave Veeneman | last post by:
Is there a simple way to pass drag-and-drop events to a child control in a UserControl? Here's an example: I have created a UserControl which contains a treeview and some text boxes. I want to be able to drag-and-drop to the treeview from outside the UserControl. Now, when I drag over the treeview in the UserControl, the UserControl gets the drag-and-drop events, but the treeview doesn't. Is there a simple way to pass drag-and-drop...
9
1760
by: Peter | last post by:
I have an Usercontrol on a WebForm, on this Usercontrol is a button, I want to save data that's residing on the WebForm when user clicks on the button that's on the UserControl. How do I call a method that's in the WebForm from the button_click event or from any other event that originate in the UserControl? Peter -- Thanks
0
900
by: Bob | last post by:
I'm trying to centralize some of the common Web User Controls used in all of our web applications (like header, footer) and put them in a web service to be called by all the other web applications. There are a couple of ways I can think of that can probably accomplish what I need. I'm most interested in rendering the control on the WS server end, and then stream the result to the consuming clients (the other web applications). I think...
6
1999
by: Anonymous | last post by:
Hello, I am loading a usercontrol with the LoadControl method and need to pass some data to the property of that control. How can I do that? THanks
1
6873
by: Will Gillen | last post by:
I know this has probably been asked before, but I can't seem to find a solid answer in any of the archives. First, before my question, please forgive my limited knowledge of the event lifecycle and page loading/rendering lifecycle.... Ok, now for the question: I have an ASPX page (page.aspx), and I have a UserControl (control.ascx). The UserControl has one textbox on the control, and one button control. I have added a public property...
12
2212
by: Joe | last post by:
Hello All: Do I have to use the LoadControl method of the Page to load a UserControl? I have a class which contains three methods (one public and two private). The class acts as a control server. It "serves" back the required control (either WebControl or UserControl) based on the contents of an xml file. The code in the webform places each control in a TableCell. My problem is that the control server works as far as returning the...
10
2430
by: Benton | last post by:
Hi there, I have a UserControl with a couple of textboxes and a couple of buttons ("Save" and "Cancel"). The Click event for this buttons is in the UserControl's codebehind of course, so here's my question. Once the UserControl is dropped onto the container page, how can I perform some action on the codebehind of the container page from the codebehind of the UserControl? For instance, suppose that the UserControl is dropped inside one...
9
1571
by: Chris | last post by:
Ok, so I have this sub I wrote, and I create a new instance of a UserControl: ctrlAPs tempctrl = new ctrlAPs(); Now, I would like to be able to use this sub I wrote for more than one UserControl, so I was trying to do something like this: private void somesub(UserControl sourcectrl) {
0
10461
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10190
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7555
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6796
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5447
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5579
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4122
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3736
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2928
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.