473,473 Members | 1,555 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Properties

Why does this work:
***********************
Public Class WebForm2
Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code ".....

Private y As String = "Hello"

Property Prop() As String
Get
Return y
End Get
Set(ByVal Value As String)
y = Value
End Set
End Property

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Prop = "GoodBye"
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button1.Click
Label1.Text = Prop
End Sub

End Class
***********************
....and not this?
***********************
Public Class WebForm2
Inherits System.Web.UI.Page
#Region " Web Form Designer Generated Code ".....

Private y As String = "Hello"

Property Prop() As String
Get
Return y
End Get
Set(ByVal Value As String)
y = Value
End Set
End Property

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button1.Click
Label1.Text = Prop
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button2.Click
Prop = "GoodBye"
End Sub

End Class
***********************
Thanks in advance for your help
Mike
Jul 21 '05 #1
5 1265
Can I presume in the 2nd example, you let the form open, click button 2 and
then button 1?

What do you get to suggest it "doesn't work"?


"Mike" <mi***********@ca.gi-de.com> wrote in message
news:c8**************************@posting.google.c om...
Why does this work:
***********************
Public Class WebForm2
Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code ".....

Private y As String = "Hello"

Property Prop() As String
Get
Return y
End Get
Set(ByVal Value As String)
y = Value
End Set
End Property

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Prop = "GoodBye"
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button1.Click
Label1.Text = Prop
End Sub

End Class
***********************
...and not this?
***********************
Public Class WebForm2
Inherits System.Web.UI.Page
#Region " Web Form Designer Generated Code ".....

Private y As String = "Hello"

Property Prop() As String
Get
Return y
End Get
Set(ByVal Value As String)
y = Value
End Set
End Property

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button1.Click
Label1.Text = Prop
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button2.Click
Prop = "GoodBye"
End Sub

End Class
***********************
Thanks in advance for your help
Mike

Jul 21 '05 #2
Change to

Private Shared Y As String = "Hello"

Then Change to

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button2.Click
Y = "GoodBye"
End Sub

You now have a static value that is updated and can be set to the Label when
you click. Not the best design, but it solves the problem.

---

Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************

"Mike" wrote:
Why does this work:
***********************
Public Class WebForm2
Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code ".....

Private y As String = "Hello"

Property Prop() As String
Get
Return y
End Get
Set(ByVal Value As String)
y = Value
End Set
End Property

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Prop = "GoodBye"
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button1.Click
Label1.Text = Prop
End Sub

End Class
***********************
....and not this?
***********************
Public Class WebForm2
Inherits System.Web.UI.Page
#Region " Web Form Designer Generated Code ".....

Private y As String = "Hello"

Property Prop() As String
Get
Return y
End Get
Set(ByVal Value As String)
y = Value
End Set
End Property

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button1.Click
Label1.Text = Prop
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button2.Click
Prop = "GoodBye"
End Sub

End Class
***********************
Thanks in advance for your help
Mike

Jul 21 '05 #3
Mike,

Does it completly not show a page, strange

Cor
Jul 21 '05 #4
Yes John, your presumption is accurate.

Sorry, I should have been more clear.
Once the webform is open, I press button2, then button1!

Therefore, why does the value 'y' still post "Hello"? I set the value
to "Goodbye" by pressing button2. No?


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 21 '05 #5
Hello Cowboy,

thanks, that's better!

If you don't mind me asking, what is a better design you're refering
too?

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 21 '05 #6

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

Similar topics

2
by: Rick Austin | last post by:
I recently had to perform a reinstalltion of Windows XP (my registry seems to have become corrupt). After this completed I had to reinstall all applications since most use the registry for settings,...
4
by: Lyn | last post by:
Hi, This question may seem a bit academic... To learn more about Access VBA, I have been enumerating the properties of various form controls. This was mostly successful and I have learned a lot...
10
by: Sunny | last post by:
Hi, I have an old problem which I couldn't solve so far. Now I have found a post in that group that gave me an idea, but I can not fully understand it. The problem is: I'm trying to use a...
6
by: JerryP | last post by:
Hello, is there a way to launch the property dialogue for a directory from my c# app ? I would also like to launch the User Account Properties from Active Directory Users and Computers, and the...
3
by: Martin Montgomery | last post by:
I have, for example, a property called myProperty. I would like, when using a property grid to display the property name as "My Property". Is this possible. Is there an attribute etc Thank ...
7
by: Donald Grove | last post by:
Is it possible to retrieve field properties from a table in access2000 using code? I have tried: " dim dbs as dao.database dim tbl as dao.tabledef dim fld as dao.field dim prop as...
1
by: Christophe Peillet | last post by:
I have a CompositeControl with two types of properties: 1.) Mapped Properties that map directly to a child control's properties (ex.: this.TextboxText = m_txt.Text). These properties are handled...
7
by: Anderskj | last post by:
Hi! I am developing a c# application. I have a interface (which can change therefore my problem) If i do like this: List<PropertyInfoproperties = new List<PropertyInfo>();...
0
by: =?Utf-8?B?UmljayBHbG9z?= | last post by:
For some unknown reason (user error?), I cannot get a NameValueCollection to persist in the app.config file. Unlike other settings, I cannot get the String Collection Editor GUI to allow my to...
4
by: FullBandwidth | last post by:
I have been perusing various blogs and MSDN pages discussing the use of event properties and the EventHandlerList class. I don't believe there's anything special about the EventHandlerList class in...
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
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...
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,...
0
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...
1
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...
0
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 project—planning, coding, testing,...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...

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.