473,756 Members | 5,595 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

dynamically writing property values to a control INSIDE of a user control?

I want to use codebehind to pass property values to a control that I've
embedded INSIDE of a user control.

In other words, let's say I have the following:

MyPage.aspx
....with the following control placed on it...
MyUserControl.a scx
.... and inside of MyUserControl.a scx, is an instance of ....
MyCommercialUpl oadControl1

I want to be able to write a property to the embedded commerical component:
MyCommercialUpl oadControl1.Tar getFolder

I want to be able write this property programmaticall y from the aspx page
that originally called the instance of MyUserControl, as follows:

[from MyPage.aspx]
MyUserControl.T argetFolder = @"c:\whateve r";

Failure #1: I attempted to add logic to the codebehind for my .ascx that
read the value of a property attached to itself, and then mapped that value
to the embedded commercial control, e.g.

MyCommercialUpl oadControl1.Tar getFolder = this.TargetFold er
// "this" refers to the ascx instance

This did not work.

Failure #2: I experimented with various scenarios involving doing the
mappings onPreInit, thinking I might be running into a page lifecycle issue.
This did not work either.

I can successfully write properties to the user control iself, but I haven't
figured out how to write properties to controls INSIDE of the control. In
all cases the debugger indicates null values where i want my properties to
end up. Can anyone help?

Thank you.
-KF

Sep 30 '06 #1
2 1561
In page, you should either embed the value in the HTML tags (ASP.NET tags)
or use Init (not Page Load) to set the value.

In the control, you can be a bit more lax and do not have to aim for Init(),
but it probably will not hurt you.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
http://gregorybeamer.spaces.live.com/

*************** *************** *************** ****
Think Outside the Box!
*************** *************** *************** ****
<ke*****@nospam .nospamwrote in message
news:Ok******** ******@TK2MSFTN GP04.phx.gbl...
>I want to use codebehind to pass property values to a control that I've
embedded INSIDE of a user control.

In other words, let's say I have the following:

MyPage.aspx
...with the following control placed on it...
MyUserControl.a scx
... and inside of MyUserControl.a scx, is an instance of ....
MyCommercialUpl oadControl1

I want to be able to write a property to the embedded commerical
component:
MyCommercialUpl oadControl1.Tar getFolder

I want to be able write this property programmaticall y from the aspx page
that originally called the instance of MyUserControl, as follows:

[from MyPage.aspx]
MyUserControl.T argetFolder = @"c:\whateve r";

Failure #1: I attempted to add logic to the codebehind for my .ascx that
read the value of a property attached to itself, and then mapped that
value to the embedded commercial control, e.g.

MyCommercialUpl oadControl1.Tar getFolder = this.TargetFold er
// "this" refers to the ascx instance

This did not work.

Failure #2: I experimented with various scenarios involving doing the
mappings onPreInit, thinking I might be running into a page lifecycle
issue. This did not work either.

I can successfully write properties to the user control iself, but I
haven't figured out how to write properties to controls INSIDE of the
control. In all cases the debugger indicates null values where i want my
properties to end up. Can anyone help?

Thank you.
-KF

Oct 1 '06 #2
Ah, good, thank you so much. Writing Page_Init() method for the aspx page
indeed solved the problem, like this:

protected void Page_Init()
{
PictureUploader AndProcessor1.P athVirtual =
"~/ni/apps/xxx/images/submitted/";
}

User controls seem so powerful in allowing you to build parameterized,
generic , reusuable functionality. It's too bad these little gotchas trip up
us newbies. I wonder if there's a way that the VS.NET IDE could cue you to
the right practices: maybe you could help it figure out intent with xml
markup or something.

Anyway, thank you very much. Now to finish my abstracted
uploading-and-image-resizing-and-cataloguing widget. ;)

-KF

"Cowboy (Gregory A. Beamer)" <No************ @comcast.netNoS pamMwrote in
message news:%2******** ********@TK2MSF TNGP06.phx.gbl. ..
In page, you should either embed the value in the HTML tags (ASP.NET tags)
or use Init (not Page Load) to set the value.

In the control, you can be a bit more lax and do not have to aim for
Init(), but it probably will not hurt you.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
http://gregorybeamer.spaces.live.com/

*************** *************** *************** ****
Think Outside the Box!
*************** *************** *************** ****
<ke*****@nospam .nospamwrote in message
news:Ok******** ******@TK2MSFTN GP04.phx.gbl...
>>I want to use codebehind to pass property values to a control that I've
embedded INSIDE of a user control.

In other words, let's say I have the following:

MyPage.aspx
...with the following control placed on it...
MyUserControl.a scx
... and inside of MyUserControl.a scx, is an instance of ....
MyCommercialUpl oadControl1

I want to be able to write a property to the embedded commerical
component:
MyCommercialUpl oadControl1.Tar getFolder

I want to be able write this property programmaticall y from the aspx page
that originally called the instance of MyUserControl, as follows:

[from MyPage.aspx]
MyUserControl.T argetFolder = @"c:\whateve r";

Failure #1: I attempted to add logic to the codebehind for my .ascx that
read the value of a property attached to itself, and then mapped that
value to the embedded commercial control, e.g.

MyCommercialUp loadControl1.Ta rgetFolder = this.TargetFold er
// "this" refers to the ascx instance

This did not work.

Failure #2: I experimented with various scenarios involving doing the
mappings onPreInit, thinking I might be running into a page lifecycle
issue. This did not work either.

I can successfully write properties to the user control iself, but I
haven't figured out how to write properties to controls INSIDE of the
control. In all cases the debugger indicates null values where i want my
properties to end up. Can anyone help?

Thank you.
-KF


Oct 1 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
2534
by: Mark English | last post by:
I'd like to write a Tkinter app which, given a class, pops up a window(s) with fields for each "attribute" of that class. The user could enter values for the attributes and on closing the window would be returned an instance of the class. The actual application I'm interested in writing would either have simple type attributes (int, string, etc.), or attributes using types already defined in a c-extension, although I'd prefer not to...
1
6027
by: Randell D. | last post by:
HELP! I am determined to stick with this... I'm getting there... for those who haven't read my earlier posts, I'm createing what should be a simple function that I can call to check that required fields in a form have values. I'm writing the values to the client using document.write only so that I can confirm that the values are there to be played with - this is not the final result so please (unless it's leading to the script failure)...
0
262
by: Mark Stokes | last post by:
Hi guys, I have seen various messages on this front, but none specific to my requirement. I have an application that dynamically loads a user control and displays it on the page during the Page_Init event. In that control I have hyperlink that loads a new window through javascript with a calendar in it.
6
565
by: Bhavin | last post by:
Anybody quickly replies it, would be a great help! I try to create dynamic array of textboxes control in ASP.NET(C#). I got the following error while I tried to assign value to ID property of dynamically created textbox. (look at my code please ) Error: “ Object reference is not set to an instance of Object” totalRows – int variable which varies with number of records in SQL table
0
1187
by: Billy | last post by:
I have a web page with a control (Control#A) on it. The control (#A) has a control (Control#B) on it which displays an exception message when set and displayed. I am creating a simple datagrid dynamically with delegates and assigning it to a placeholder on control #A. If, within a delegate of the dynamically built datagrid, I set a property on control #B, it sets fine but fails to reflect this on the displayed page. There is no...
0
3173
by: Diane Yocom | last post by:
I'm very new to ASP.Net and probably jumped in a little over my head, but... I'm trying to create a user control that will control navigation through my site. It's sortof like Amazon.com, where there are tabs at the top with "submenu" buttons showing below the selected tab. The data that defines the tabs and submenus is stored in an XML file and I'm using nested repeaters to build them dynamically. I've got it working pretty well, except...
2
1598
by: Web Team | last post by:
Hi All, I'm in the process of writing a eich text editor web custom control. The actual text/HTML is displayed/editied in a DIV layer, which I have created like this: output.Write("<span class=" & EditDivCSSClass & " id=" & Me.ID & " " & strContentEditable & " wrap>" & _strText & "</span>")
6
11081
by: | last post by:
I have made some user controls with custom properties. I can set those properties on instances of my user controls, and I have programmed my user control to do useful visual things in response to how those properties are set. I want to be able to do two other things: a) add User control instances to my page, filling in the place of placeholder controls, and b) programmatically setting custom properties on those dynamically spawned...
12
13270
by: vbnewbie | last post by:
I am having problems accessing properties of dynamically generated objects in VB2005. Can someone please help? In a nutshell: My app creates an equal number of checkboxes and labels that share the same Tag number. (I thought it might help) The checkboxes name is a concatenation of "chkCancel" and a number that represents the order in which they were created: chkCancel0 (Tag = 0) chkCancel1 (Tag = 1)
0
9275
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10040
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
9846
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,...
0
8713
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7248
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
6534
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();...
1
3806
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
3359
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2666
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.