Re: 2.0: setting TextBox.Text

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



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/
.



Relevant Pages

  • Re: Intermittent "Circular file references are not allowed"
    ... I have treble checked and all my User Controls are in a single directory. ... None of them reference each other anywhere. ... Microsoft MVP ... I do have a couple of controls in different folders. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Array of Text Box; knowing which one caused event
    ... you pass a reference to the specific form control as an argument to ... In HTML an ID attribute must be unique on any document. ... is a collection of all controls within the form. ... The formal parameter of this function has been given the identifier - ...
    (comp.lang.javascript)
  • Re: "Global" objects
    ... does for purposes of this discussion) and a public method to return it. ... reference to "the designer" was the ambiguous part, ... it should be added to the Controls Collection of the Container ... are added to other Container Controls in the InitializeComponent method. ...
    (microsoft.public.dotnet.framework.windowsforms)
  • Re: Setting a referenced object to null
    ... "The controls" is an extremely non-specific description. ... of data that is fetched from a database. ... the variable reference something else. ... need to filter what is seen and what is not seen. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Intermittent "Circular file references are not allowed"
    ... That said, I still got one Circular ref error yesterday, rebuilt again and ... I do have a couple of controls in different folders. ... >> know this is related to user controls that reference each other. ...
    (microsoft.public.dotnet.framework.aspnet)