473,657 Members | 2,397 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help in Web User controls ???

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.getV alue

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
Nov 19 '05 #1
5 1302
did you set the textbox as Public in the control?

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

"serge calderara" wrote:
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.getV alue

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

Nov 19 '05 #2
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("valu e")
End Get
Set(ByVal Value As String)
ViewState("valu e") = Value

End Set

Then somewhere on my webcontrol code I set :
ViewState("valu e")=mytxtBox.te xt

thanks
"Curt_C [MVP]" wrote:
did you set the textbox as Public in the control?

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

"serge calderara" wrote:
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.getV alue

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

Nov 19 '05 #3
ok... then on your page declare the UserControl and access the TextBox

Dim userControl1 as YourUserControl
Dim strSomeText as String = userControl1.Ge tValue

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.Yo urTexBox.Text
--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com

"serge calderara" wrote:
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("valu e")
End Get
Set(ByVal Value As String)
ViewState("valu e") = Value

End Set

Then somewhere on my webcontrol code I set :
ViewState("valu e")=mytxtBox.te xt

thanks
"Curt_C [MVP]" wrote:
did you set the textbox as Public in the control?

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

"serge calderara" wrote:
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.getV alue

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

Nov 19 '05 #4
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
"Curt_C [MVP]" wrote:
ok... then on your page declare the UserControl and access the TextBox

Dim userControl1 as YourUserControl
Dim strSomeText as String = userControl1.Ge tValue

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.Yo urTexBox.Text
--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com

"serge calderara" wrote:
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("valu e")
End Get
Set(ByVal Value As String)
ViewState("valu e") = Value

End Set

Then somewhere on my webcontrol code I set :
ViewState("valu e")=mytxtBox.te xt

thanks
"Curt_C [MVP]" wrote:
did you set the textbox as Public in the control?

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

"serge calderara" wrote:

> 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.getV alue
>
> 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
>
>

Nov 19 '05 #5
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

"serge calderara" wrote:
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
"Curt_C [MVP]" wrote:
ok... then on your page declare the UserControl and access the TextBox

Dim userControl1 as YourUserControl
Dim strSomeText as String = userControl1.Ge tValue

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.Yo urTexBox.Text
--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com

"serge calderara" wrote:
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("valu e")
End Get
Set(ByVal Value As String)
ViewState("valu e") = Value

End Set

Then somewhere on my webcontrol code I set :
ViewState("valu e")=mytxtBox.te xt

thanks
"Curt_C [MVP]" wrote:

> did you set the textbox as Public in the control?
>
> --
> Curt Christianson
> site: http://www.darkfalz.com
> blog: http://blog.darkfalz.com
>
>
>
> "serge calderara" wrote:
>
> > 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.getV alue
> >
> > 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
> >
> >

Nov 19 '05 #6

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

Similar topics

4
2000
by: Mike | last post by:
Please help this is driving me nuts. I have 2 forms, 1 user class and I am trying to implement a singleton class. Form 1 should create a user object and populate some properties in user. Form2 should then have access to those user properties. I am not getting the property value from user that was set in form1. Sorry for posting so much code but I need help bad. How do i make this work? Thanks Mike
2
2555
by: mark | last post by:
I've been working on an Access 2000 database for a couple of weeks now. I took a course in access about a year ago, a crash course, and I learned a ton, but I didn't touch Access for the year since then so I forgot everything I learned : ( So this little project I envisioned has turned out to be much harder than I thought. But I think I'm close with it, so I want to see it through. What I wanted to create is a database that will track my...
0
3635
by: Patrick | last post by:
I'm working on a contact management application, and need a hand with one aspect... Here's what I want to create: ------------------------------------ A form split into two parts. There is a datagrid on the left side that lists names and perhaps a couple of other key fields. The user can click on a record in the datagrid, which should automatically pull up details on that record in the various text boxes and other controls on the right...
5
2386
by: MFC | last post by:
Ok, after three C# books, (C# How to Program, Programming in the Key of C#, and C# Weekend Crash Course) and three weeks, I believe I have tried everything to make a certain form function correctly. I am trying to learn C# after playing around for a bit with procedural programming with PHP, not OOP, and believe I have learned quite a bit in three weeks, just not enough to accomplish this one task. If anyone has a bit of free time and...
3
5258
by: Navin | last post by:
Hello friends... On a single asp.net web page i have a single server-side form that contains a couple of user-controls. Each user control has its own functionality and contains server-side textbox controls, requiredfieldvalidator controls which validate the textboxes, and a linkbutton control that postbacks the web page. The problem is, when the user clicks on the linkbutton control on one user control, the requiredfieldvalidator gets...
2
3018
by: paul meaney | last post by:
All, myself and another developer have been staring blankly at a screen for the past 48 hours and are wondering just what stunningly obvious thing we are missing. We are trying to load up 2 or more user controls dynamically by adding to a placeholder defined in page_load. I've included the sample code for how we are accessing one. The user controls are not rocket science - just a few text boxes with public accessor properties. We've...
1
7565
by: Shourie | last post by:
I've noticed that none of the child controls events are firing for the first time from the dynamic user control. Here is the event cycle. 1) MainPage_load 2) User control1_Load user clicks a dropdown in UC1 _________________________ 1) MainPage_Load 2) User Control_1 Load
2
1802
by: Peter Jackson | last post by:
I'm using v2 of the UIP App. Block. I've created all my .aspx pages, all of which contain .ascx user controls. The .ascx user controls provide the standard server controls (i.e., LinkButtons, etc.) for the user to navigate the site and perform their tasks. None of the site's actual functionality is contained in the .aspx pages--they're just kinda containers for all the .ascx user controls. So, I'm to the point in the UIP App. Block where I...
3
2227
by: Tim::.. | last post by:
Can someone please help.... I'm having major issues with a user control I'm tring to create! I an trying to execute a sub called UploadData() from a user control which I managed to do but for some reason I keep getting the error: Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
0
2398
by: Mike Collins | last post by:
I someone can please help, I am about at an end in trying to figure this out. I am adding some dynamic controls to my page (I found out that I was supposed to be doing that in the oninit event, which I am). I now want to read the text/values of those controls. I have found out that I can read the values if I wait until Page_Load, but then I have the same questions showing up again (along with the new questions) and I do not want them to....
0
8402
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8315
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
8829
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...
0
8734
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8508
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
5633
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();...
0
4323
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2733
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
1627
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.