Can't we make the string variable 'static' ?
 
-----Original Message-----
From: Dean Fiala [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, May 18, 2004 1:33 PM
To: [EMAIL PROTECTED]
Subject: RE: [AspNetAnyQuestionIsOk] How to store multiple values in a
string without overriding the pervious one
 
You have to remember that each time you press the button, you are
posting
back to the server, and the server creates a new instance of the page.
hence
any module level variables are reinitialized.  If you want to maintain
state
between calls to the page you must either store the value on the page
(in a
control or in Viewstate) or in a session variable.

In this case storing on the page would be the best approach.

You can either store the string directly in the lblMessage control...

Sub SubmitBtn_AddValue(Sender as Object, E as EventArgs)

Dim WorkExperience as String

WorkExperience + = "IT Officer"
WorkExperience + = "01,"
WorkExperience + = "2002,"
WorkExperience + = "02,"
WorkExperience + = "2002,"
WorkExperience + = "Hello2,"
WorkExperience + = "+"


lblMessage.Text += WorkExperience

End Sub

or in a viewstate variable...


Sub SubmitBtn_AddValue(Sender as Object, E as EventArgs)

Dim WorkExperience as String

if not isNothing(ViewState("SavedWorkExperience")) then
      WorkExperience = ViewState("SavedWorkExperience")
End if

WorkExperience + = "IT Officer"
WorkExperience + = "01,"
WorkExperience + = "2002,"
WorkExperience + = "02,"
WorkExperience + = "2002,"
WorkExperience + = "Hello2,"
WorkExperience + = "+"


lblMessage.Text += WorkExperience

ViewState("SavedWorkExperience") = WorkExperience

End Sub

HTH,

Dean Fiala
-----------------------------
Very Practical Software, Inc.
http://www.vpsw.com/links.aspx



-----Original Message-----
From: Mustafa Ali Bamboat [mailto:[EMAIL PROTECTED]
Sent: Tuesday, May 18, 2004 7:06 AM
To: [EMAIL PROTECTED]
Subject: [AspNetAnyQuestionIsOk] How to store multiple values in a
string without overriding the pervious one


Hi Friends,

I am new user of ASP.NET. I'm trying to store the multiple values in
a string, but very time it override the pervious value whenever I
call the function through a command button.

Please help me out.

Here I also enclosing the sample coding for your reference

<[EMAIL PROTECTED] Language=VB Debug=True %>
<Script runat="server">

Dim WorkExperience as String


Sub Page_Load(ByVal Sender as Object, ByVal E as EventArgs)


lblMessage.Text = "Press a button !"

WorkExperience +=" Hello !"

End Sub



Sub SubmitBtn_AddValue(Sender as Object, E as EventArgs)



WorkExperience + = "IT Officer"
WorkExperience + = "01,"
WorkExperience + = "2002,"
WorkExperience + = "02,"
WorkExperience + = "2002,"
WorkExperience + = "Hello2,"
WorkExperience + = "+"


lblMessage.Text= WorkExperience

End Sub

</Script>

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

<BR>
<BR>
</form>
</body>
</html>

Try to run the above cited code. You will find a button named
as "Add Value", if u press this button it will display a dummy
value, now I want that if you press this Add Value more than once
time then it must display the dummy value respectively.

For Example: Press this button 3 times then it must show the same
value 3 times.

Please reply me soon because all my work is halt due to this problem

Looking forward to your reply...

Regards,
Mustafa Bamboat
[EMAIL PROTECTED]






Yahoo! Groups Links










Yahoo! Groups Sponsor
ADVERTISEMENT
click here
<http://rd.yahoo.com/SIG=1297h7avh/M=295196.4901138.6071305.3001176/D=gr
oups/S=1705006764:HM/EXP=1084988721/A=2128215/R=0/SIG=10se96mf6/*http:/c
ompanion.yahoo.com> 
 
<http://us.adserver.yahoo.com/l?M=295196.4901138.6071305.3001176/D=group
s/S=:HM/A=2128215/rand=522308563> 
 
  _____  

Yahoo! Groups Links
*         To visit your group on the web, go to:
http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/
  
*         To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]
cribe> 
  
*         Your use of Yahoo! Groups is subject to the Yahoo! Terms of
Service <http://docs.yahoo.com/info/terms/> . 


[Non-text portions of this message have been removed]



------------------------ Yahoo! Groups Sponsor ---------------------~-->
Yahoo! Domains - Claim yours for only $14.70
http://us.click.yahoo.com/Z1wmxD/DREIAA/yQLSAA/saFolB/TM
---------------------------------------------------------------------~->

 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
     http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/

<*> To unsubscribe from this group, send an email to:
     [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
     http://docs.yahoo.com/info/terms/
 

Reply via email to