problem with get value from textbox after get it value in load page


hi every one
 i have problem with my web site
when i get textbox value in load page
 
and Changed textbox
the page do not take last value .   it take value in load page
 
this is code:Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
 
TextBox1.Text = "aa"
End Sub
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
MsgBox(TextBox1.Text)
End Sub
 
when i press button
message write "aa" while i changed the textbox
 
please if enyone knowen help me
 
-1
mrmyself
9/13/2008 8:35:03 PM
📁 asp.net.web-forms
📃 93655 articles.
⭐ 6 followers.

💬 3 Replies
👁️‍🗨️ 2705 Views



 Hi
This code 
TextBox1.Text = "aa"
will be called every time you submit the page , but it must be called just the first time the page is loaded , so add this if 
If Not IsPostBack
TextBox1.Text = "aa"
end if 
 
 

Regards,

Anas Ghanem.


Note:Please Don't hesitate to click "Report Abuse" link if you noticed something wrong on the forums (like duplicate ,Off-topic,offensive,or any post that violates the website "TERMS OF USE"). -- Thanks!

1
anas
9/13/2008 9:41:21 PM

Hi ,
Your code worked well with me , are you sure no another code that changes the value of TextBox1.Text ?
 

myLabel.Text = "Just \"Mark my post As Answer\" , if it helps you";
1
Dr_no
9/13/2008 11:59:58 PM

hi
mr anas thank you very very much this is  what i need
and its work perfectly
 
dr_no
thank you for ansering me
 
 
1
mrmyself
9/14/2008 3:31:44 AM
Reply: