Help in Web User controls ???

G

Guest

Dear all,
I try to study Web user control .For that I have created a simple text box
with button as a webuser control which has 2 properties.

Then I drop my user control on a web page for testing.
I have read that If we need to retrive Webuser control properties from the
web page, we need to place the code in the PAge_Prerender event of the form
which contains it.

So what I have do is that I place that webuser control on a web page called
WebPage1.aspx then on the pre_render event of that page I have place
following code :

dim sText as string
sText= myUserCtrl.getValue

Doing that return an error when executin about object not initiliaze. Then
when setting a break point on line above, effecively the myUserCtrl is nothing

So it is not fully loaded then

On which part can I retrive myuserCtrl properties value ?

thanks for your help
regards
serge
 
G

Guest

What do you mean by that ?

I simply drop a textbox control on my webuser control in design mode, then
create public properties as follow :



Public Property GetValue() As String
Get
Return ViewState("value")
End Get
Set(ByVal Value As String)
ViewState("value") = Value

End Set

Then somewhere on my webcontrol code I set :
ViewState("value")=mytxtBox.text

thanks
 
G

Guest

ok... then on your page declare the UserControl and access the TextBox

Dim userControl1 as YourUserControl
Dim strSomeText as String = userControl1.GetValue

Although you dont need the GetValue(), you could just call the .Text
property directly if the TextBox is declared Public

Dim userControl1 as YourUserControl
Dim strSomeText as String = userControl1.YourTexBox.Text


--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com
 
G

Guest

This is what I have done.

In which palce in the page should I call my control property ?

If I place it in Page_load event, it fails cause the control is not yet
fully loaded
I read in ms press books that the controls gets loaded at the end of the
page_load event

how to do then ?

regards
serge
 
G

Guest

As for where in your code...
Are you trying to read or write to the textbox? If you are trying to read it
you will want to wait till it's populated and they do something to PostBack,
in which case you can do it in the Load or the individual event (Button
Click?) that causes the postback.


--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com
 

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

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,078
Latest member
MakersCBDBlood

Latest Threads

Top