Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Building Controls > saving text values of dynamically created textboxes

Reply
Thread Tools

saving text values of dynamically created textboxes

 
 
YunusEmre
Guest
Posts: n/a
 
      12-28-2004
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


 
Reply With Quote
 
 
 
 
R. Thomas, aka Xtreme.Net
Guest
Posts: n/a
 
      12-28-2004
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
>
>
>

 
Reply With Quote
 
 
 
 
YunusEmre
Guest
Posts: n/a
 
      12-28-2004
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







 
Reply With Quote
 
R. Thomas, aka Xtreme.Net
Guest
Posts: n/a
 
      12-29-2004
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
 
Reply With Quote
 
YunusEmre
Guest
Posts: n/a
 
      12-30-2004
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:ACD2C1D3-D8B5-46F9-ACD2-...
> 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



 
Reply With Quote
 
YunusEmre
Guest
Posts: n/a
 
      12-30-2004
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" <emrenews-> 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:ACD2C1D3-D8B5-46F9-ACD2-...
>> 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

>
>



 
Reply With Quote
 
R. Thomas, aka Xtreme.Net
Guest
Posts: n/a
 
      12-30-2004
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" <emrenews-> 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:ACD2C1D3-D8B5-46F9-ACD2-...
> >> 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

> >
> >

>
>
>

 
Reply With Quote
 
YunusEmre
Guest
Posts: n/a
 
      12-30-2004
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:E402C5D8-D0DC-469A-B4DF-...
> 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" <emrenews-> 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:ACD2C1D3-D8B5-46F9-ACD2-...
>> >> 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
>> >
>> >

>>
>>
>>



 
Reply With Quote
 
R. Thomas, aka Xtreme.Net
Guest
Posts: n/a
 
      12-30-2004
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:ACD2C1D3-D8B5-46F9-ACD2-...
> > 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

>
>
>

 
Reply With Quote
 
YunusEmre
Guest
Posts: n/a
 
      12-30-2004
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:0634DD46-F02A-4DAE-99E3-...
>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:ACD2C1D3-D8B5-46F9-ACD2-...
>> > 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

>>
>>
>>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Affecting a dynamically created drop down from another dynamically created drop down. msimmons ASP .Net 0 07-16-2009 03:17 PM
Managing ViewState of a dynamically created Custom Composite Server Control -(where the original is also dynamically created) dickster ASP .Net Building Controls 0 12-08-2005 09:32 AM
How do you query the values of textboxes dynamically created in a Panel container?? SD ASP .Net 3 06-23-2005 10:06 PM
Get Value From Dynamically Created TextBoxes...... RC ASP .Net 1 06-07-2005 05:44 AM
TextBoxes created dynamically : How to store data? Forconi Boris via .NET 247 ASP .Net 2 06-18-2004 09:09 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57