Simple question ???

S

serge calderara

Dear all,

I have build a simple Web user control which contains 2 labels named Lab1
and Lab2.

I defined property for that control to change the .Text property of both ogf
them.
Then I drag my user control on an empty form whcih contains only my created
user control.

Then I set the text property of those control through my Web form code as :

dim myControl as new USerContrl
myControl.SetText ="Test value"

This code is place in my webForm Page_PreRender, but when it runs my user
control labels text property has not change, it contain default value.

What I am doing wrong ?
Is it the properway to do or should I use a Control Libary ?

Thanks for your help
regards
serge
 
H

Harish Ranganathan

Hi,

Try placing the same code in the Page_Load event. It should work fine.
Alternatively you can also set the property in the Usercontrol declaration in
your aspx page.

Write back if this doesnt help.

Thanks.
 
S

serge calderara

Hi, it does not help

Once agin to be sure you understand :
I have created a simple user control which contains only a simple label
server control as MyLabel.

In my user control code I have a property as follow:

Public Property LineName() As String
Get
'Return m_sLineName
Return ViewState("Line")
End Get
Set(ByVal Value As String)
ViewState("Line") = Value
End Set
End Property

Then I drag my control on an empty webForm. SO by dragging I can see only a
generic control graphic (not my label)

Then what I am trying to do is display MyLabel.Text property on my WebFrom
according to the property value I have set.
Then on my WebForm code load event I have the following :

dim ctlReel = New myControl
ctlReel.LineName = "Test"

When executing, my WebForm lable control as the value of "label" instead of
Test

It is clear that if I add on my WebForm a new lable and populate its value
like:

myWeFrom.NewLable.Text= ctReel.LineName

Then I get displayed the "Test" string previously set
But this is not what I want, I would like that when my page display, it show
myUserControl value previously set

What is wrong ?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,810
Latest member
Kassie0918

Latest Threads

Top