Thursday, March 22, 2012

Text value does not stay the same when updated...

Hello:

I am in a very weird situation and hope that someone can help me shed some light on this...

I have a form that contains two textboxes, in one text box it asks for the users first name, in the other textbox it shows a template message that will be sent to the user...

So in my code I have on


If page.ispostback = "false" Then
txttemplatemessage.text = "Hello " & txtfirstname.text & "<custom message goes here>"
End If

With the above code, when the form is updated and a custom message is inserted... It works just fine... But if you tried to make changes to the txtfirstname.text, it does not accept the changes since it checks for ispostback = "false"...

Then When I try the following:


txttemplatemessage.text = "Hello " & txtfirstname.text & "<custom message goes here>"

With the above code, when the form is udpated the custom message inserted in the actual txttemplatemessage, does not show, since it overrides with when the information is posted back... But the txtfirstname update works fine...

How can I make both of these work? While still keeping the same logic if possible... Any suggestions?A wild shot...


If page.ispostback = "false" Then

txttemplatemessage.text = "Hello " & txtfirstname.text & "<custom message goes here>"
Else

If txtfirstname.text <> String.Empty Then
txttemplatemessage.text = "Hello " & txtfirstname.text & "<custom message goes here>"
End if

End If


That would not work since during the post back it re-assigns the values back to txttemplatemessage... so if the user had changed the message in there, his updated changes would just disappear with the generic template again... Any other suggestions?

0 comments:

Post a Comment