Re: 2.0: setting TextBox.Text
- From: Göran Andersson <guffa@xxxxxxxxx>
- Date: Sat, 13 May 2006 20:30:02 +0200
Of course there is no visible result. You have kept a reference to a TextBox object that is no longer used.
The controls of a page is created when the page is requested. Then the page is rendered as HTML, and the controls used to do it are disposed. If the page is requested again, new controls are created, used and disposed.
If you keep a reference to one of those controls, you will just be holding on to an object that will never again be used to create a page.
Are you trying to change the value of an input field that is displayed in a web page? Then you have to do it using Javascript. Pages are requested from the server, and once they are sent to the browser there is no connection between the browser and the server. You can't send something from the server to a page that has already been sent to the browser.
R.A.M. wrote:
Hello,.
Could you help me plase? I need to set Text property of TextBox when
second page is displayed and active. On first page I have:
Birth date: <asp:TextBox ID="BirthDate" runat="server"
ValidationGroup="BirthDate" />
...
Session["BirthDate"] = BirthDate;
On second page I have:
<asp:Calendar ID="Calendar" runat="server" OnSelectionChanged="Calendar_SelectionChanged" />
...
protected void Calendar_SelectionChanged(object sender,
EventArgs e)
{
if (Session["BirthDate"] != null)
((TextBox) Session["BirthDate"]).Text =
Calendar.SelectedDate.ToString().Substring(0, 10); }
But it doesn't work - no visible result.
Could you tell me plase what's wrong? Thank you very much!
/RAM/
- References:
- 2.0: setting TextBox.Text
- From: R . A . M .
- 2.0: setting TextBox.Text
- Prev by Date: gridview events question.
- Next by Date: Re: Treeview Node Type
- Previous by thread: Re: setting TextBox.Text
- Next by thread: Treeview Node Type
- Index(es):
Relevant Pages
|