saving text values of dynamically created textboxes

Discussion in 'ASP .Net Building Controls' started by YunusEmre, Dec 28, 2004.

  1. YunusEmre

    YunusEmre Guest

    I have many textboxes that are created dynamically as child controls of my
    custom control.

    I know that I must recreate them after each postback and also know that I
    can use the ViewState property to save the state of my controls.

    What I dont know is when to save the values into viewstate. I want to save
    the text in the textboxes. Since it is the user that enters the text into
    those, I need some event like OnJustBeforePostBack to save the latest values
    in the textboxes.

    Any help will be appreciated.
    Thanks in advance...

    Emre
     
    YunusEmre, Dec 28, 2004
    #1
    1. Advertising

  2. Whenever a event takes place, i.e when user presses the submit button, you
    should store the values of your textboxes to the viewstate. I think that
    should be safe enough...
    Hth...
    R. Thomas

    "YunusEmre" wrote:

    > I have many textboxes that are created dynamically as child controls of my
    > custom control.
    >
    > I know that I must recreate them after each postback and also know that I
    > can use the ViewState property to save the state of my controls.
    >
    > What I dont know is when to save the values into viewstate. I want to save
    > the text in the textboxes. Since it is the user that enters the text into
    > those, I need some event like OnJustBeforePostBack to save the latest values
    > in the textboxes.
    >
    > Any help will be appreciated.
    > Thanks in advance...
    >
    > Emre
    >
    >
    >
     
    R. Thomas, aka Xtreme.Net, Dec 28, 2004
    #2
    1. Advertising

  3. YunusEmre

    YunusEmre Guest

    I guess that will not be enough because the OnClick event handler of the
    button is executed AFTER the postback so my dynamic control is already gone
    and recreated and so its value is already wiped out.

    Emre
     
    YunusEmre, Dec 28, 2004
    #3
  4. R. Thomas, aka Xtreme.Net, Dec 29, 2004
    #4
  5. YunusEmre

    YunusEmre Guest

    In my situation there is no DB. I store the info that is used to create the
    TextBox also in the ViewState.
    After reading the article I tried something. I put the following code...

    protected override void OnLoad(EventArgs e)

    {

    base.OnLoad (e);

    TrialCtrl= new TextBox();

    this.Controls.Add( TryCtrl );

    TrialCtrl.ID = "trialctrl";

    }



    ....into my class as an OnLoad event handler and it worked and also didn't
    work. What worked is that the value that the user enters into the TextBox
    survives the first PostBack, but not the others. After the second and
    following postbacks the text is lost again. ... makes no sense ?!?? Any idea
    why this happens ?



    "R. Thomas, aka Xtreme.Net" <> wrote
    in message news:...
    > Sorry I didn't read your first post properly.
    > Ok, check this link out. It will solve your problem..
    > http://xtremedotnet.blogdrive.com/archive/53.html
    > Do lemme know if you managed to get out of your problem...
    > Hth..
    > R. Thomas
     
    YunusEmre, Dec 30, 2004
    #5
  6. YunusEmre

    YunusEmre Guest

    the article talk about creating the control in the OnLoad event handler. And
    since the OnLoad event handler runs after the LoadViewState stage, I can
    have my data in the viewstate that will be used to create the controls.
    If I can get the code below run as it should run, I guess creating the
    controls in the OnLoad event handler will solve my problem...

    YunusEmre

    "YunusEmre" <> wrote in message
    news:OveQ$...
    > In my situation there is no DB. I store the info that is used to create
    > the TextBox also in the ViewState.
    > After reading the article I tried something. I put the following code...
    >
    > protected override void OnLoad(EventArgs e)
    >
    > {
    >
    > base.OnLoad (e);
    >
    > TrialCtrl= new TextBox();
    >
    > this.Controls.Add( TryCtrl );
    >
    > TrialCtrl.ID = "trialctrl";
    >
    > }
    >
    >
    >
    > ...into my class as an OnLoad event handler and it worked and also didn't
    > work. What worked is that the value that the user enters into the TextBox
    > survives the first PostBack, but not the others. After the second and
    > following postbacks the text is lost again. ... makes no sense ?!?? Any
    > idea why this happens ?
    >
    >
    >
    > "R. Thomas, aka Xtreme.Net" <>
    > wrote in message
    > news:...
    >> Sorry I didn't read your first post properly.
    >> Ok, check this link out. It will solve your problem..
    >> http://xtremedotnet.blogdrive.com/archive/53.html
    >> Do lemme know if you managed to get out of your problem...
    >> Hth..
    >> R. Thomas

    >
    >
     
    YunusEmre, Dec 30, 2004
    #6
  7. So you managed to solve it?
    P.S : If this post was helpful, pls click 'Yes' on top of this post. Thanks
    R. Thomas

    "YunusEmre" wrote:

    > the article talk about creating the control in the OnLoad event handler. And
    > since the OnLoad event handler runs after the LoadViewState stage, I can
    > have my data in the viewstate that will be used to create the controls.
    > If I can get the code below run as it should run, I guess creating the
    > controls in the OnLoad event handler will solve my problem...
    >
    > YunusEmre
    >
    > "YunusEmre" <> wrote in message
    > news:OveQ$...
    > > In my situation there is no DB. I store the info that is used to create
    > > the TextBox also in the ViewState.
    > > After reading the article I tried something. I put the following code...
    > >
    > > protected override void OnLoad(EventArgs e)
    > >
    > > {
    > >
    > > base.OnLoad (e);
    > >
    > > TrialCtrl= new TextBox();
    > >
    > > this.Controls.Add( TryCtrl );
    > >
    > > TrialCtrl.ID = "trialctrl";
    > >
    > > }
    > >
    > >
    > >
    > > ...into my class as an OnLoad event handler and it worked and also didn't
    > > work. What worked is that the value that the user enters into the TextBox
    > > survives the first PostBack, but not the others. After the second and
    > > following postbacks the text is lost again. ... makes no sense ?!?? Any
    > > idea why this happens ?
    > >
    > >
    > >
    > > "R. Thomas, aka Xtreme.Net" <>
    > > wrote in message
    > > news:...
    > >> Sorry I didn't read your first post properly.
    > >> Ok, check this link out. It will solve your problem..
    > >> http://xtremedotnet.blogdrive.com/archive/53.html
    > >> Do lemme know if you managed to get out of your problem...
    > >> Hth..
    > >> R. Thomas

    > >
    > >

    >
    >
    >
     
    R. Thomas, aka Xtreme.Net, Dec 30, 2004
    #7
  8. YunusEmre

    YunusEmre Guest

    I am afraid not, as I said earlier, the value in the textbox(TrialCtrl)
    survives the first PostBack but not the second one or the ones after that...
    After the second postback the text in the textbox is gone and any other
    thing you write there after that stage doesn't persist through postbacks any
    more.


    "R. Thomas, aka Xtreme.Net" <> wrote
    in message news:...
    > So you managed to solve it?
    > P.S : If this post was helpful, pls click 'Yes' on top of this post.
    > Thanks
    > R. Thomas
    >
    > "YunusEmre" wrote:
    >
    >> the article talk about creating the control in the OnLoad event handler.
    >> And
    >> since the OnLoad event handler runs after the LoadViewState stage, I can
    >> have my data in the viewstate that will be used to create the controls.
    >> If I can get the code below run as it should run, I guess creating the
    >> controls in the OnLoad event handler will solve my problem...
    >>
    >> YunusEmre
    >>
    >> "YunusEmre" <> wrote in message
    >> news:OveQ$...
    >> > In my situation there is no DB. I store the info that is used to create
    >> > the TextBox also in the ViewState.
    >> > After reading the article I tried something. I put the following
    >> > code...
    >> >
    >> > protected override void OnLoad(EventArgs e)
    >> >
    >> > {
    >> >
    >> > base.OnLoad (e);
    >> >
    >> > TrialCtrl= new TextBox();
    >> >
    >> > this.Controls.Add( TryCtrl );
    >> >
    >> > TrialCtrl.ID = "trialctrl";
    >> >
    >> > }
    >> >
    >> >
    >> >
    >> > ...into my class as an OnLoad event handler and it worked and also
    >> > didn't
    >> > work. What worked is that the value that the user enters into the
    >> > TextBox
    >> > survives the first PostBack, but not the others. After the second and
    >> > following postbacks the text is lost again. ... makes no sense ?!?? Any
    >> > idea why this happens ?
    >> >
    >> >
    >> >
    >> > "R. Thomas, aka Xtreme.Net" <>
    >> > wrote in message
    >> > news:...
    >> >> Sorry I didn't read your first post properly.
    >> >> Ok, check this link out. It will solve your problem..
    >> >> http://xtremedotnet.blogdrive.com/archive/53.html
    >> >> Do lemme know if you managed to get out of your problem...
    >> >> Hth..
    >> >> R. Thomas
    >> >
    >> >

    >>
    >>
    >>
     
    YunusEmre, Dec 30, 2004
    #8
  9. I made a simple aspx page an put this in my onload
    TrialCtrl= new TextBox();
    form.Controls.Add( TrialCtrl );
    TrialCtrl.ID = "trialctrl";
    with public TextBox TrialCtrl; declared.
    It works good for me... the values stays there after every postback...
    I think they way you are overloading and inheritting has some problems..
    You were saying you are overloading right?
    Lets look into that.. cause the above code i showed u works perfectly fine...
    Hth...
    R. Thomas

    "YunusEmre" wrote:

    > In my situation there is no DB. I store the info that is used to create the
    > TextBox also in the ViewState.
    > After reading the article I tried something. I put the following code...
    >
    > protected override void OnLoad(EventArgs e)
    >
    > {
    >
    > base.OnLoad (e);
    >
    > TrialCtrl= new TextBox();
    >
    > this.Controls.Add( TryCtrl );
    >
    > TrialCtrl.ID = "trialctrl";
    >
    > }
    >
    >
    >
    > ....into my class as an OnLoad event handler and it worked and also didn't
    > work. What worked is that the value that the user enters into the TextBox
    > survives the first PostBack, but not the others. After the second and
    > following postbacks the text is lost again. ... makes no sense ?!?? Any idea
    > why this happens ?
    >
    >
    >
    > "R. Thomas, aka Xtreme.Net" <> wrote
    > in message news:...
    > > Sorry I didn't read your first post properly.
    > > Ok, check this link out. It will solve your problem..
    > > http://xtremedotnet.blogdrive.com/archive/53.html
    > > Do lemme know if you managed to get out of your problem...
    > > Hth..
    > > R. Thomas

    >
    >
    >
     
    R. Thomas, aka Xtreme.Net, Dec 30, 2004
    #9
  10. YunusEmre

    YunusEmre Guest

    you are right. It works well on a clean page. Something I do is probaby
    making it fail. I will try to figure out what it is and get back to you.
    Thanks...
    Emre

    "R. Thomas, aka Xtreme.Net" <> wrote
    in message news:...
    >I made a simple aspx page an put this in my onload
    > TrialCtrl= new TextBox();
    > form.Controls.Add( TrialCtrl );
    > TrialCtrl.ID = "trialctrl";
    > with public TextBox TrialCtrl; declared.
    > It works good for me... the values stays there after every postback...
    > I think they way you are overloading and inheritting has some problems..
    > You were saying you are overloading right?
    > Lets look into that.. cause the above code i showed u works perfectly
    > fine...
    > Hth...
    > R. Thomas
    >
    > "YunusEmre" wrote:
    >
    >> In my situation there is no DB. I store the info that is used to create
    >> the
    >> TextBox also in the ViewState.
    >> After reading the article I tried something. I put the following code...
    >>
    >> protected override void OnLoad(EventArgs e)
    >>
    >> {
    >>
    >> base.OnLoad (e);
    >>
    >> TrialCtrl= new TextBox();
    >>
    >> this.Controls.Add( TryCtrl );
    >>
    >> TrialCtrl.ID = "trialctrl";
    >>
    >> }
    >>
    >>
    >>
    >> ....into my class as an OnLoad event handler and it worked and also
    >> didn't
    >> work. What worked is that the value that the user enters into the TextBox
    >> survives the first PostBack, but not the others. After the second and
    >> following postbacks the text is lost again. ... makes no sense ?!?? Any
    >> idea
    >> why this happens ?
    >>
    >>
    >>
    >> "R. Thomas, aka Xtreme.Net" <>
    >> wrote
    >> in message news:...
    >> > Sorry I didn't read your first post properly.
    >> > Ok, check this link out. It will solve your problem..
    >> > http://xtremedotnet.blogdrive.com/archive/53.html
    >> > Do lemme know if you managed to get out of your problem...
    >> > Hth..
    >> > R. Thomas

    >>
    >>
    >>
     
    YunusEmre, Dec 30, 2004
    #10
  11. YunusEmre

    YunusEmre Guest

    after some painful hours before the screen I realized that it is not the
    postback that makes it fail but it is the DataBind(). The postbacks which
    call the DataBind method eventually make my TrialCtrl fail to persist its
    text through postbacks.
    I have some buttons on my custom control (which is a grid by the way), some
    of them are used for paging and sorting stuff. And naturally the event
    handlers of these buttons call the DataBind() sometime after doing that
    "paging and sorting stuff". When DataBind() is called, it somehow causes the
    text in the textbox to be deleted.


    "YunusEmre" <> wrote in message
    news:...
    > you are right. It works well on a clean page. Something I do is probaby
    > making it fail. I will try to figure out what it is and get back to you.
    > Thanks...
    > Emre
    >
    > "R. Thomas, aka Xtreme.Net" <>
    > wrote in message
    > news:...
    >>I made a simple aspx page an put this in my onload
    >> TrialCtrl= new TextBox();
    >> form.Controls.Add( TrialCtrl );
    >> TrialCtrl.ID = "trialctrl";
    >> with public TextBox TrialCtrl; declared.
    >> It works good for me... the values stays there after every postback...
    >> I think they way you are overloading and inheritting has some problems..
    >> You were saying you are overloading right?
    >> Lets look into that.. cause the above code i showed u works perfectly
    >> fine...
    >> Hth...
    >> R. Thomas
    >>
    >> "YunusEmre" wrote:
    >>
    >>> In my situation there is no DB. I store the info that is used to create
    >>> the
    >>> TextBox also in the ViewState.
    >>> After reading the article I tried something. I put the following code...
    >>>
    >>> protected override void OnLoad(EventArgs e)
    >>>
    >>> {
    >>>
    >>> base.OnLoad (e);
    >>>
    >>> TrialCtrl= new TextBox();
    >>>
    >>> this.Controls.Add( TryCtrl );
    >>>
    >>> TrialCtrl.ID = "trialctrl";
    >>>
    >>> }
    >>>
    >>>
    >>>
    >>> ....into my class as an OnLoad event handler and it worked and also
    >>> didn't
    >>> work. What worked is that the value that the user enters into the
    >>> TextBox
    >>> survives the first PostBack, but not the others. After the second and
    >>> following postbacks the text is lost again. ... makes no sense ?!?? Any
    >>> idea
    >>> why this happens ?
    >>>
    >>>
    >>>
    >>> "R. Thomas, aka Xtreme.Net" <>
    >>> wrote
    >>> in message news:...
    >>> > Sorry I didn't read your first post properly.
    >>> > Ok, check this link out. It will solve your problem..
    >>> > http://xtremedotnet.blogdrive.com/archive/53.html
    >>> > Do lemme know if you managed to get out of your problem...
    >>> > Hth..
    >>> > R. Thomas
    >>>
    >>>
    >>>

    >
    >
     
    YunusEmre, Dec 31, 2004
    #11
  12. So, is everything ok now?
    R. Thomas

    "YunusEmre" wrote:

    > after some painful hours before the screen I realized that it is not the
    > postback that makes it fail but it is the DataBind(). The postbacks which
    > call the DataBind method eventually make my TrialCtrl fail to persist its
    > text through postbacks.
    > I have some buttons on my custom control (which is a grid by the way), some
    > of them are used for paging and sorting stuff. And naturally the event
    > handlers of these buttons call the DataBind() sometime after doing that
    > "paging and sorting stuff". When DataBind() is called, it somehow causes the
    > text in the textbox to be deleted.
    >
    >
    > "YunusEmre" <> wrote in message
    > news:...
    > > you are right. It works well on a clean page. Something I do is probaby
    > > making it fail. I will try to figure out what it is and get back to you.
    > > Thanks...
    > > Emre
    > >
    > > "R. Thomas, aka Xtreme.Net" <>
    > > wrote in message
    > > news:...
    > >>I made a simple aspx page an put this in my onload
    > >> TrialCtrl= new TextBox();
    > >> form.Controls.Add( TrialCtrl );
    > >> TrialCtrl.ID = "trialctrl";
    > >> with public TextBox TrialCtrl; declared.
    > >> It works good for me... the values stays there after every postback...
    > >> I think they way you are overloading and inheritting has some problems..
    > >> You were saying you are overloading right?
    > >> Lets look into that.. cause the above code i showed u works perfectly
    > >> fine...
    > >> Hth...
    > >> R. Thomas
    > >>
    > >> "YunusEmre" wrote:
    > >>
    > >>> In my situation there is no DB. I store the info that is used to create
    > >>> the
    > >>> TextBox also in the ViewState.
    > >>> After reading the article I tried something. I put the following code...
    > >>>
    > >>> protected override void OnLoad(EventArgs e)
    > >>>
    > >>> {
    > >>>
    > >>> base.OnLoad (e);
    > >>>
    > >>> TrialCtrl= new TextBox();
    > >>>
    > >>> this.Controls.Add( TryCtrl );
    > >>>
    > >>> TrialCtrl.ID = "trialctrl";
    > >>>
    > >>> }
    > >>>
    > >>>
    > >>>
    > >>> ....into my class as an OnLoad event handler and it worked and also
    > >>> didn't
    > >>> work. What worked is that the value that the user enters into the
    > >>> TextBox
    > >>> survives the first PostBack, but not the others. After the second and
    > >>> following postbacks the text is lost again. ... makes no sense ?!?? Any
    > >>> idea
    > >>> why this happens ?
    > >>>
    > >>>
    > >>>
    > >>> "R. Thomas, aka Xtreme.Net" <>
    > >>> wrote
    > >>> in message news:...
    > >>> > Sorry I didn't read your first post properly.
    > >>> > Ok, check this link out. It will solve your problem..
    > >>> > http://xtremedotnet.blogdrive.com/archive/53.html
    > >>> > Do lemme know if you managed to get out of your problem...
    > >>> > Hth..
    > >>> > R. Thomas
    > >>>
    > >>>
    > >>>

    > >
    > >

    >
    >
    >
     
    R. Thomas, aka Xtreme.Net, Dec 31, 2004
    #12
  13. YunusEmre

    YunusEmre Guest

    No, the call to DataBind still does harm and I don't know why it does that.



    "R. Thomas, aka Xtreme.Net" <> wrote
    in message news:...
    > So, is everything ok now?
    > R. Thomas
    >
    > "YunusEmre" wrote:
    >
    >> after some painful hours before the screen I realized that it is not the
    >> postback that makes it fail but it is the DataBind(). The postbacks which
    >> call the DataBind method eventually make my TrialCtrl fail to persist its
    >> text through postbacks.
    >> I have some buttons on my custom control (which is a grid by the way),
    >> some
    >> of them are used for paging and sorting stuff. And naturally the event
    >> handlers of these buttons call the DataBind() sometime after doing that
    >> "paging and sorting stuff". When DataBind() is called, it somehow causes
    >> the
    >> text in the textbox to be deleted.
    >>
    >>
    >> "YunusEmre" <> wrote in message
    >> news:...
    >> > you are right. It works well on a clean page. Something I do is probaby
    >> > making it fail. I will try to figure out what it is and get back to
    >> > you.
    >> > Thanks...
    >> > Emre
    >> >
    >> > "R. Thomas, aka Xtreme.Net" <>
    >> > wrote in message
    >> > news:...
    >> >>I made a simple aspx page an put this in my onload
    >> >> TrialCtrl= new TextBox();
    >> >> form.Controls.Add( TrialCtrl );
    >> >> TrialCtrl.ID = "trialctrl";
    >> >> with public TextBox TrialCtrl; declared.
    >> >> It works good for me... the values stays there after every postback...
    >> >> I think they way you are overloading and inheritting has some
    >> >> problems..
    >> >> You were saying you are overloading right?
    >> >> Lets look into that.. cause the above code i showed u works perfectly
    >> >> fine...
    >> >> Hth...
    >> >> R. Thomas
    >> >>
    >> >> "YunusEmre" wrote:
    >> >>
    >> >>> In my situation there is no DB. I store the info that is used to
    >> >>> create
    >> >>> the
    >> >>> TextBox also in the ViewState.
    >> >>> After reading the article I tried something. I put the following
    >> >>> code...
    >> >>>
    >> >>> protected override void OnLoad(EventArgs e)
    >> >>>
    >> >>> {
    >> >>>
    >> >>> base.OnLoad (e);
    >> >>>
    >> >>> TrialCtrl= new TextBox();
    >> >>>
    >> >>> this.Controls.Add( TryCtrl );
    >> >>>
    >> >>> TrialCtrl.ID = "trialctrl";
    >> >>>
    >> >>> }
    >> >>>
    >> >>>
    >> >>>
    >> >>> ....into my class as an OnLoad event handler and it worked and also
    >> >>> didn't
    >> >>> work. What worked is that the value that the user enters into the
    >> >>> TextBox
    >> >>> survives the first PostBack, but not the others. After the second and
    >> >>> following postbacks the text is lost again. ... makes no sense ?!??
    >> >>> Any
    >> >>> idea
    >> >>> why this happens ?
    >> >>>
    >> >>>
    >> >>>
    >> >>> "R. Thomas, aka Xtreme.Net" <>
    >> >>> wrote
    >> >>> in message news:...
    >> >>> > Sorry I didn't read your first post properly.
    >> >>> > Ok, check this link out. It will solve your problem..
    >> >>> > http://xtremedotnet.blogdrive.com/archive/53.html
    >> >>> > Do lemme know if you managed to get out of your problem...
    >> >>> > Hth..
    >> >>> > R. Thomas
    >> >>>
    >> >>>
    >> >>>
    >> >
    >> >

    >>
    >>
    >>
     
    YunusEmre, Dec 31, 2004
    #13
  14. There's gotta be something that you are doin wrong in ur code...
    Maybe you'd like to post some code.??
    R. Thomas

    "YunusEmre" wrote:

    > No, the call to DataBind still does harm and I don't know why it does that.
    >
    >
    >
    > "R. Thomas, aka Xtreme.Net" <> wrote
    > in message news:...
    > > So, is everything ok now?
    > > R. Thomas
    > >
    > > "YunusEmre" wrote:
    > >
    > >> after some painful hours before the screen I realized that it is not the
    > >> postback that makes it fail but it is the DataBind(). The postbacks which
    > >> call the DataBind method eventually make my TrialCtrl fail to persist its
    > >> text through postbacks.
    > >> I have some buttons on my custom control (which is a grid by the way),
    > >> some
    > >> of them are used for paging and sorting stuff. And naturally the event
    > >> handlers of these buttons call the DataBind() sometime after doing that
    > >> "paging and sorting stuff". When DataBind() is called, it somehow causes
    > >> the
    > >> text in the textbox to be deleted.
    > >>
    > >>
    > >> "YunusEmre" <> wrote in message
    > >> news:...
    > >> > you are right. It works well on a clean page. Something I do is probaby
    > >> > making it fail. I will try to figure out what it is and get back to
    > >> > you.
    > >> > Thanks...
    > >> > Emre
    > >> >
    > >> > "R. Thomas, aka Xtreme.Net" <>
    > >> > wrote in message
    > >> > news:...
    > >> >>I made a simple aspx page an put this in my onload
    > >> >> TrialCtrl= new TextBox();
    > >> >> form.Controls.Add( TrialCtrl );
    > >> >> TrialCtrl.ID = "trialctrl";
    > >> >> with public TextBox TrialCtrl; declared.
    > >> >> It works good for me... the values stays there after every postback...
    > >> >> I think they way you are overloading and inheritting has some
    > >> >> problems..
    > >> >> You were saying you are overloading right?
    > >> >> Lets look into that.. cause the above code i showed u works perfectly
    > >> >> fine...
    > >> >> Hth...
    > >> >> R. Thomas
    > >> >>
    > >> >> "YunusEmre" wrote:
    > >> >>
    > >> >>> In my situation there is no DB. I store the info that is used to
    > >> >>> create
    > >> >>> the
    > >> >>> TextBox also in the ViewState.
    > >> >>> After reading the article I tried something. I put the following
    > >> >>> code...
    > >> >>>
    > >> >>> protected override void OnLoad(EventArgs e)
    > >> >>>
    > >> >>> {
    > >> >>>
    > >> >>> base.OnLoad (e);
    > >> >>>
    > >> >>> TrialCtrl= new TextBox();
    > >> >>>
    > >> >>> this.Controls.Add( TryCtrl );
    > >> >>>
    > >> >>> TrialCtrl.ID = "trialctrl";
    > >> >>>
    > >> >>> }
    > >> >>>
    > >> >>>
    > >> >>>
    > >> >>> ....into my class as an OnLoad event handler and it worked and also
    > >> >>> didn't
    > >> >>> work. What worked is that the value that the user enters into the
    > >> >>> TextBox
    > >> >>> survives the first PostBack, but not the others. After the second and
    > >> >>> following postbacks the text is lost again. ... makes no sense ?!??
    > >> >>> Any
    > >> >>> idea
    > >> >>> why this happens ?
    > >> >>>
    > >> >>>
    > >> >>>
    > >> >>> "R. Thomas, aka Xtreme.Net" <>
    > >> >>> wrote
    > >> >>> in message news:...
    > >> >>> > Sorry I didn't read your first post properly.
    > >> >>> > Ok, check this link out. It will solve your problem..
    > >> >>> > http://xtremedotnet.blogdrive.com/archive/53.html
    > >> >>> > Do lemme know if you managed to get out of your problem...
    > >> >>> > Hth..
    > >> >>> > R. Thomas
    > >> >>>
    > >> >>>
    > >> >>>
    > >> >
    > >> >
    > >>
    > >>
    > >>

    >
    >
    >
     
    R. Thomas, aka Xtreme.Net, Jan 3, 2005
    #14
  15. There's gotta be something that you are doin wrong in ur code...
    Maybe you'd like to post some code.??
    R. Thomas

    "YunusEmre" wrote:

    > No, the call to DataBind still does harm and I don't know why it does that.
    >
    >
    >
    > "R. Thomas, aka Xtreme.Net" <> wrote
    > in message news:...
    > > So, is everything ok now?
    > > R. Thomas
    > >
    > > "YunusEmre" wrote:
    > >
    > >> after some painful hours before the screen I realized that it is not the
    > >> postback that makes it fail but it is the DataBind(). The postbacks which
    > >> call the DataBind method eventually make my TrialCtrl fail to persist its
    > >> text through postbacks.
    > >> I have some buttons on my custom control (which is a grid by the way),
    > >> some
    > >> of them are used for paging and sorting stuff. And naturally the event
    > >> handlers of these buttons call the DataBind() sometime after doing that
    > >> "paging and sorting stuff". When DataBind() is called, it somehow causes
    > >> the
    > >> text in the textbox to be deleted.
    > >>
    > >>
    > >> "YunusEmre" <> wrote in message
    > >> news:...
    > >> > you are right. It works well on a clean page. Something I do is probaby
    > >> > making it fail. I will try to figure out what it is and get back to
    > >> > you.
    > >> > Thanks...
    > >> > Emre
    > >> >
    > >> > "R. Thomas, aka Xtreme.Net" <>
    > >> > wrote in message
    > >> > news:...
    > >> >>I made a simple aspx page an put this in my onload
    > >> >> TrialCtrl= new TextBox();
    > >> >> form.Controls.Add( TrialCtrl );
    > >> >> TrialCtrl.ID = "trialctrl";
    > >> >> with public TextBox TrialCtrl; declared.
    > >> >> It works good for me... the values stays there after every postback...
    > >> >> I think they way you are overloading and inheritting has some
    > >> >> problems..
    > >> >> You were saying you are overloading right?
    > >> >> Lets look into that.. cause the above code i showed u works perfectly
    > >> >> fine...
    > >> >> Hth...
    > >> >> R. Thomas
    > >> >>
    > >> >> "YunusEmre" wrote:
    > >> >>
    > >> >>> In my situation there is no DB. I store the info that is used to
    > >> >>> create
    > >> >>> the
    > >> >>> TextBox also in the ViewState.
    > >> >>> After reading the article I tried something. I put the following
    > >> >>> code...
    > >> >>>
    > >> >>> protected override void OnLoad(EventArgs e)
    > >> >>>
    > >> >>> {
    > >> >>>
    > >> >>> base.OnLoad (e);
    > >> >>>
    > >> >>> TrialCtrl= new TextBox();
    > >> >>>
    > >> >>> this.Controls.Add( TryCtrl );
    > >> >>>
    > >> >>> TrialCtrl.ID = "trialctrl";
    > >> >>>
    > >> >>> }
    > >> >>>
    > >> >>>
    > >> >>>
    > >> >>> ....into my class as an OnLoad event handler and it worked and also
    > >> >>> didn't
    > >> >>> work. What worked is that the value that the user enters into the
    > >> >>> TextBox
    > >> >>> survives the first PostBack, but not the others. After the second and
    > >> >>> following postbacks the text is lost again. ... makes no sense ?!??
    > >> >>> Any
    > >> >>> idea
    > >> >>> why this happens ?
    > >> >>>
    > >> >>>
    > >> >>>
    > >> >>> "R. Thomas, aka Xtreme.Net" <>
    > >> >>> wrote
    > >> >>> in message news:...
    > >> >>> > Sorry I didn't read your first post properly.
    > >> >>> > Ok, check this link out. It will solve your problem..
    > >> >>> > http://xtremedotnet.blogdrive.com/archive/53.html
    > >> >>> > Do lemme know if you managed to get out of your problem...
    > >> >>> > Hth..
    > >> >>> > R. Thomas
    > >> >>>
    > >> >>>
    > >> >>>
    > >> >
    > >> >
    > >>
    > >>
    > >>

    >
    >
    >
     
    R. Thomas, aka Xtreme.Net, Jan 3, 2005
    #15
  16. YunusEmre

    YunusEmre Guest

    I finally figured it out. The call to Databind clears the Controls
    collection. I overrided DataBind method and after calling the base class's
    DataBind I called my function which adds the controls to the collection
    again.

    Thus, after DataBind clears the controls collection I add put them there
    again. This solved my problem.

    Thank you very much for your attention. I really appreciate it.
    Thanks a lot.
    Emre
     
    YunusEmre, Jan 3, 2005
    #16
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Forconi Boris via .NET 247

    TextBoxes created dynamically : How to store data?

    Forconi Boris via .NET 247, Jun 17, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    386
    Trevor Benedict R
    Jun 18, 2004
  2. SD
    Replies:
    3
    Views:
    464
    =?Utf-8?B?S2V6emE=?=
    Jun 23, 2005
  3. RC
    Replies:
    1
    Views:
    595
    Teemu Keiski
    Jun 7, 2005
  4. Nathan Sokalski

    Problem using dynamically created textboxes

    Nathan Sokalski, Jun 17, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    396
    Nathan Sokalski
    Jun 17, 2005
  5. msimmons
    Replies:
    0
    Views:
    514
    msimmons
    Jul 16, 2009
Loading...

Share This Page