473,386 Members | 1,734 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

question about an MS article of user control

Hi,
I have a question concerning how to manipulate the properties in the user
control, and there is an interesting article about this from Microsoft:
http://msdn.microsoft.com/library/de...properties.asp

My situation is i have a user control resides in the aspx page. And In
the aspx page's html, i set the following:
<ucl:myControl id="title" EditText="Add New Topic" ></ucl:myControl>

And in my control i declare:
protected System.Web.UI.WebControls.HyperLink EditButton;
public String EditText = null; // why use String instead of string
....

EditButton.Text = EditText;
....

Then i ran the program, the HyperLink button EditButton's text was set to
"Add New Topic". I just don't know how it works.(The article tell the
exactly the same technique.)
How come EditText will be automatically set to "Add New Topic"?
What i am thinking about is:
Then program first keep the value pair of EditText and "Add New Topic"
from the ucl section, then when run to the user section, it find the field
EditText and set it to the value provided in the ucl section. If i am wrong
please correct me.

I am more like to do the following way
protected System.Web.UI.WebControls.HyperLink EditButton;

public string EditButtonText{
get{return EditButton.Text;}
set{EditButton.Text = EditText;} // This is from the aspx's ucl
section.
}
public String EditText = null; // why use String instead of string
(if i set like: private String EditText = null; The program will not
locate it and set "Add New Topic to it, why?")
....

EditButton.Text = EditText;
....


Nov 18 '05 #1
1 1335
Hi Green,

Thanks for posting here. As for the wonders you mentioned I'll try
explaining based on my understanding:

1. Why the example use "String" rather than "string"
=============================================
The "String" is just the System.String class which is the standard dotnet
framework class type. The "string" is System.String's alias in C# language(
just a keyword help to declare the System.String more convenient). They're
just the same one.

2. How does the value in <uc:Control attr= "value" > be assigned to the
actual control instance's field(property) at runtime.
=============================================
We can first discuss from the ASP.NET control's design-time support. Since
each control class may have
some properties or field and they support assignment at designtime. Then,
where do we store the assigned values ? As for the public property(fields),
the answer is just the control's inline attribute in the aspx page source.
For example:
<uc:Control Title="Title Text" ..>

The "Title Test" is just the value we assigned at design-time, and at
runtime, when the page is requested and intilizing, it will constructed the
Control class if there are such inline assignment:
Title="Title Text"
it will use this value to initialize the control's certain property/field.
This intializing is done before we can access the control on the page.
Sequence:
Parse aspx template file ---->Page init----> construct controls and set the
intial values from the inline values
------> other events we can handle(such as Page_load).
3. Why the inline setting not work if we change the public field into
private.
=============================================
This is a normal behavior since all the fields or properties we want to
expose to outer must declare as
public, otherwise, they're invisble to the Control's users.

Above are some of my understanding, if you have any other questions or
ideas, please feel free to post here. Thanks.

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.)

Nov 18 '05 #2

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

Similar topics

1
by: dixp | last post by:
I'm new to writing multithreaded apps and I have a design question. I have a winforms app and a class which has a method that does processing which is time intensive. I want the user to be able...
6
by: mkobus | last post by:
Im relatively new, so please be patient with me... I need to update a parent .aspx screen from a popup and close the popup. Normally I would use...
2
by: Stan Sainte-Rose | last post by:
Hi guys, I have a page with several textboxes.. In the same page, I set a user control with a button. I would like to know how to catch the different values from the textboxes when I click on the...
7
by: Dan Nash | last post by:
Hi guys Ok, i have an aspx with a user control. In the user controls pageload i set a property (mystring = "test";). i then want to access that from the page_load of the aspx thats using the...
5
by: Darrel | last post by:
I thought this warranted a new thread. Yesterday I asked about access relatively static content...is it better to read from the DB, or just grab a text file. It was suggested that I use the DB...
2
by: carla | last post by:
We have a bunch of articles that visitors to our website can read. They do a search, and we present a list of matching article links. The files are named sequentially: art1.htm, art2.htm, art3,...
2
by: Frankie | last post by:
I have a user control into which I insert a bunch of controls dynamically. I have it all working just fine - Everything is there on Postback, etc. I load this user control into a hosting ASPX...
8
by: pigeonrandle | last post by:
Hi, Has anyone had any experience with hooking messages in other application windows (like SPY++). I want to listen for WM_MOVE messages, but can only seem to find examples of Keyboard and Mouse...
2
by: Crimson* | last post by:
I've got a table with an entry type as "OLE Object" in Access 2003. In the form that the table is linked to I want to insert an image (BMP) for each record. However, when I attempt to do so the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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,...

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.