View Single Post
  #4 (permalink)  
Old May 23rd, 2004, 07:32 AM
planoie's Avatar
planoie planoie is offline
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts

A more important issue here is that you must understand the postback and viewstate models of The value of the asp label is maintained in viewstate automatically. So when you call the button click handler, you only need to get the current value of the label out and append to it. Also, you need to set the label's default text only on the FIRST pagehit (use IsPostback in the Page_Load method).

<%@Page Language=VB Debug=True %>
<Script runat="server">

Sub Page_Load(ByVal Sender as Object, ByVal E as EventArgs)
    If Not IsPostback Then
        lblMessage.Text = "Press a button !"
    End If
End Sub

Sub SubmitBtn_AddValue(Sender as Object, E as EventArgs)

    Dim WorkExperience as String = lblMessage.Text
    WorkExperience +=" Hello !"
    WorkExperience + = "IT Officer"
    WorkExperience + = "01,"
    WorkExperience + = "2002,"
    WorkExperience + = "02,"
    WorkExperience + = "2002,"
    WorkExperience + = "Hello2,"
    WorkExperience + = "+"

    lblMessage.Text= WorkExperience

End Sub


    <form runat="server">
        <asp:Label id="lblMessage" Text="" runat="server" />
        <asp:Button id="butAlone" text="Add Value" OnClick="SubmitBtn_AddValue" runat="server" />


Work smarter, not harder
Reply With Quote