Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > send information to user control

Reply
Thread Tools

send information to user control

 
 
Green
Guest
Posts: n/a
 
      09-21-2004
Hi,
I have an user control. And normally you can set the property of the user
control so as to send the information of the page to the user control like
below:
<TagPrefix: TagName id="***" property1="***" property2="***" ...> in the
aspx page, and in the user control you can pick those information up to do
something.
But it is kind of fixed solution. Can i dynamically do this?

My situation is:
I need to set a variant or property in the user control (ascx)
according to a value(in aspx) which will be decided at runtime of the aspx
page. How can i do this?

I appreciate in advance!!


 
Reply With Quote
 
 
 
 
Juno
Guest
Posts: n/a
 
      09-21-2004
Hi,

You use
yourcontrol.property1="****"
yourcontrol.property2="****"
in your code.

--
Juno
MCSD.NET, MCDBA, MCSE
----------------------------------------------------------
Support Team of EasyDotNet, INC. http://www.EasyDotNet.com
DataForm.NET - The most powerful data entry web server control for ASP.NET



"Green" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi,
> I have an user control. And normally you can set the property of the

user
> control so as to send the information of the page to the user control like
> below:
> <TagPrefix: TagName id="***" property1="***" property2="***" ...> in the
> aspx page, and in the user control you can pick those information up to do
> something.
> But it is kind of fixed solution. Can i dynamically do this?
>
> My situation is:
> I need to set a variant or property in the user control (ascx)
> according to a value(in aspx) which will be decided at runtime of the aspx
> page. How can i do this?
>
> I appreciate in advance!!
>
>



 
Reply With Quote
 
 
 
 
Steven Cheng[MSFT]
Guest
Posts: n/a
 
      09-22-2004
Hi Green,

As for this problem, I thinkwe can just set the usercontrol's property at
runtime as
usercontrol.PropertyName = XXX;

And the keypoint is that we need to retrieve the UserControl's reference
and CAST the reference to the UserControl's Actual Type. We can use the
"FindControl" method to locate the UserControl from its parent Container
Control, for example:


========aspx page=============
<form id="Form1" method="post" runat="server">
<uc1ropertyControl id="pcOne" Title="MyTitle"
runat="server"></uc1ropertyControl>
</form>

=========code behind=====================
public class testpage1 : System.Web.UI.Page
{

private void Page_Load(object sender, System.EventArgs e)
{
HtmlForm form = this.FindControl("Form1") as HtmlForm;
PropertyControl pc = form.FindControl("pcOne") as PropertyControl;

pc.Title = "Changed Title";

}
.........
}

Hope helps.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
User Control to Control Other User Control Jonathan Wood ASP .Net 4 02-02-2010 03:41 PM
ASP.NET send email -> Autheticate User information via LOTUS NOTES Eric Layman ASP .Net 3 05-10-2007 12:16 PM
Send credentials/user information accross applcations securely? =?Utf-8?B?RGFuaWVsIERpIFZpdGE=?= ASP .Net 0 09-11-2006 04:20 PM
persisting changes to a control outside a user control from the user control? Mad Scientist Jr ASP .Net 0 03-22-2006 08:02 AM
Manipulating a User Control from another User Control Tom Rowton ASP .Net 2 08-01-2003 08:18 PM



Advertisments