TextBoxes

Merge text from texboxes on seperate web pages

  • (2 Pages)
  • +
  • 1
  • 2

17 Replies - 2664 Views - Last Post: 07 December 2009 - 09:12 AM Rate Topic: -----

#1 charliechilds   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 25
  • Joined: 30-October 09

TextBoxes

Post icon  Posted 26 November 2009 - 06:35 AM

Hello All,

I am quite new to web development.

I am building a site to display images and retreive a list of users favourite 100 images.

Around 300 images ( size about 120 x 160 ) are shown over 10 pages.

I use a table to show the images - 3 images (+ padding) in width and 10 images long.

Each image has a label of the image name underneath it.

Each image is an image button in order to force the image name from the label ( underneath image) into a fixed position textbox on the right of the page - thus creating a text written list of the images the user clicks on in the textbox.

The above work well in debug and forms a nice list per individual web page.

I am using Visual Web Developer 2008.

MY QUESTION IS THIS: Can anyone help me join the content from the seperate textboxes which reside on seperate web pages?

I have so far imagined that I could do this by adding the content of each text box to a final textbox with a total of all the other textboxes.

I understand that the code to join the content of text boxes which are on the same web page but I can't work out out to get the text from the textboxes on seperate web pages in order to put the total of the textboxes into a text box on a final page.

I would also like the pages to be longer so as to have less pages but am having trouble with the scroll position of textbox if more than 30 lines of text are added. That is another story unless you wish to help with that in this thread.


Any help with this is much appreciated.

Best wishes and many thanks,
Charlie

Is This A Good Question/Topic? 0
  • +

Replies To: TextBoxes

#2 ramesh866   User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 91
  • Joined: 03-October 09

Re: TextBoxes

Posted 26 November 2009 - 07:34 AM

i did not understand much of your exp. but i think you want to get the value from a textbox in one form to the other form.

this goes in second web page load event(or where ever its applicable)
  TextBox txt = (TextBox)Page.PreviousPage.FindControl("TextBox1");
		TextBox1.Text = txt.Text


Was This Post Helpful? 0
  • +
  • -

#3 charliechilds   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 25
  • Joined: 30-October 09

Re: TextBoxes

Posted 26 November 2009 - 10:09 AM

Hi Ramesh, ( My you're an early bird )

Thanks for the code - you are right about what I want to do but I am having a problem with that code.

My textBoxes and Page names are as follows :

The first textbox is called TextBox2 - it is on page Default.aspx

I want to get the text from that textbox (TextBox2) to another textbox called TextBox1 on the next page which is called Default2.aspx

I adjusted your code to my page name and textbox names and added it to page load event for Default2.aspx:

my code :
	Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

		TextBox1 txt = (TextBox2)Page.Default.FindControl("TextBox2");
		TextBox1.Text = txt.Text

	End Sub




I have blue wiggly lines under all the first line of code with the error messages
" Property access must assign to the property or use its value"
Also
"TextBox2 is not declared"
Also
"txt is not declared"

I tried adding -
		Dim txt As String
		Dim TextBox2 As String


- in Page Load sub but no luck.

I know my beginner status is showing badly here and I really appreciate your help.

I have tried several different versions of the code in the form load event and have come up with -
TextBox1.Text = Default(aspx).FindControl(TextBox2.Text)


- which kind of makes sense and the only blue wiggly line is under the words "Default" which is the name of the previous page.

I will keep trying but would be very grateful if you could carry on helping me with this pleeeease? Me - :wacko:

Lots and lots of thanks :D :D

Charlie
Was This Post Helpful? 0
  • +
  • -

#4 ramesh866   User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 91
  • Joined: 03-October 09

Re: TextBoxes

Posted 26 November 2009 - 10:28 AM

wt code i gave was in c#.. you are using vb.. it might be different in vb.. which i got no idea.. anyhow will try it in vb :)
Was This Post Helpful? 0
  • +
  • -

#5 ramesh866   User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 91
  • Joined: 03-October 09

Re: TextBoxes

Posted 26 November 2009 - 10:35 AM

in your code
  TextBox1 txt = (TextBox2)Page.Default.FindControl("TextBox2");
		TextBox1.Text = txt.Text



dont give the name as textbox1.. just put "TextBox" since you are creating an object of textbox
Was This Post Helpful? 0
  • +
  • -

#6 ramesh866   User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 91
  • Joined: 03-October 09

Re: TextBoxes

Posted 26 November 2009 - 10:57 AM

Dim txt As TextBox = CType(Page.PreviousPage.FindControl("TextBox1"), TextBox)
TextBox1.Text = txt.Text

vb code

Dim txt As TextBox = CType(Page.PreviousPage.FindControl("TextBox1"), TextBox)
TextBox1.Text = txt.Text




vb code
Was This Post Helpful? 0
  • +
  • -

#7 charliechilds   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 25
  • Joined: 30-October 09

Re: TextBoxes

Posted 26 November 2009 - 11:51 AM

Hi Ramesh,

No blue wiggly lines :)

But - NullReferenceException was unhandled :blink:

I tried adding the New keyword to the code just befor "txt" but then I got a lot of wiggly blue lines.

I can tell you that I am VERY HAPPY just to know that this CAN be done even though I have not made it work yet. It would be useful for me to know that there a way of collecting text from txtbox on a specific page rather than just PreviousPage if you can confirm that.

Any advice on this code is a bonus at the moment.

Many Thanks
Charlie
Was This Post Helpful? 0
  • +
  • -

#8 ramesh866   User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 91
  • Joined: 03-October 09

Re: TextBoxes

Posted 26 November 2009 - 11:59 AM

did you give any input in the first textbox from where the data is fetched??
Was This Post Helpful? 0
  • +
  • -

#9 Footsie   User is offline

  • D.I.C Regular
  • member icon

Reputation: 24
  • View blog
  • Posts: 370
  • Joined: 20-September 07

Re: TextBoxes

Posted 26 November 2009 - 12:28 PM

Why not add the contents of the textboxes to the session state?

You can then add them all to the Session object then call them up and output them on the final page.

In C# you would do that like this:
Session.Add("MyTextBoxValue",TextBox1.Text);



Then to get it out again, on your second page:

TextBox2.Text = Session["MyTextBoxValue"].ToString();


Was This Post Helpful? 1
  • +
  • -

#10 charliechilds   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 25
  • Joined: 30-October 09

Re: TextBoxes

Posted 26 November 2009 - 01:49 PM

View Postramesh866, on 26 Nov, 2009 - 10:59 AM, said:

did you give any input in the first textbox from where the data is fetched??




Hi Ramesh,

No - the text box is empty until the first page is loaded and a user clicks an image button - that is what creates the text in the textbox.

Thanks for your interest. keep it coming if you have time. ;)

Charlie
Was This Post Helpful? 0
  • +
  • -

#11 charliechilds   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 25
  • Joined: 30-October 09

Re: TextBoxes

Posted 26 November 2009 - 01:57 PM

View PostFootsie, on 26 Nov, 2009 - 11:28 AM, said:

Why not add the contents of the textboxes to the session state?

You can then add them all to the Session object then call them up and output them on the final page.

In C# you would do that like this:
Session.Add("MyTextBoxValue",TextBox1.Text);



Then to get it out again, on your second page:

TextBox2.Text = Session["MyTextBoxValue"].ToString();




Hi Footsie,

That is something new to me but it looks like a good idea.

I have just been to MSDN Session State Overview to findout what it is and it does look like a possible option. I use the Visual Basic language in VWD but the code you gave looks very similar to that which I am learning about.
Thanks for the advice - it certainly appears to be worth looking into.
Would you know how long is it before sessions time out or if this can be adjusted?

Thanks again I feel so much better to be out of the dark on this matter.

Best wishes,
Charlie
Was This Post Helpful? 0
  • +
  • -

#12 Footsie   User is offline

  • D.I.C Regular
  • member icon

Reputation: 24
  • View blog
  • Posts: 370
  • Joined: 20-September 07

Re: TextBoxes

Posted 27 November 2009 - 12:45 AM

I think the standard Session state period is about 20min. This can be changed by editing your web.config file and setting the session timeout to a longer period.
<system.web>
  <sessionState timeout="40"/>

</system.web>


As you asked, here is a bit more detail about where you would use the Session object:
Presumably you have some sort of submit or continue button on Page 1 to get to Page 2. You would then set the Session object within that event handler. Sorry about the C# code but VB is pretty similar:

Page 1:

  protected void SubmitButton_Click(object sender, EventArgs e)
    {
        Session.Add("MyTextBoxValue",TextBox1.Text);
    }



You can then get the value back out by adding TextBox2.Text = Session["MyTextBoxValue"].ToString(); in Page 2's Page_Load event. Nothing needs to be added to the top of the page (no using in c# - Import in VB I think).

Options other than Session State that might work - ViewState / Cookies - in case you want to do some more research - :P

This post has been edited by Footsie: 27 November 2009 - 12:47 AM

Was This Post Helpful? 1
  • +
  • -

#13 charliechilds   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 25
  • Joined: 30-October 09

Re: TextBoxes

Posted 27 November 2009 - 09:36 AM

Thanks very much Footsie,

I am not sure but I don't think the web server in Visual Web Developer allows IIS because it works with local host.

I will try and see if it can be done with VWD but otherwise will have to wait - nevertheless, it is good to be prepared :hungry: .
Was This Post Helpful? 0
  • +
  • -

#14 charliechilds   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 25
  • Joined: 30-October 09

Re: TextBoxes

Posted 27 November 2009 - 10:13 AM

Hi Ramesh,
I have just noticed that you have been busy with your postings in the last month or so - big thanks for your replys to me. You may have noticed that Footsie has mentioned Session State which is probably a very good idea but I don't think I can use it in Visual Web Developer so I must postpone its use. Mean while I am still interested in getting this working with what I have.

I have added some permenant text to the textbox (TextBox2) on the first page but am still getting the same error re "exception". I understand you do C# so if it is hassle don't worry. If it's not I am still interested in progressing with your method and am grateful for any further suggestions. :rolleyes: :)
Was This Post Helpful? 0
  • +
  • -

#15 charliechilds   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 25
  • Joined: 30-October 09

Re: TextBoxes

Posted 28 November 2009 - 05:42 AM

Hi Footsie,

The more I think about this the more perfect it is. Providing I am not being under cautious, it solves everything I need to get started. Please tell me if I am wrong:-

User can add text to text box and navigate away from page. Session state stores that text and can load it back into the text box if user navigates back to that page - thus allowing user to change their mind about text previously added if they so wish. In my case this is likely to happen on multiple pages. - Then when user is finally satisfied that all textboxes contain the correct details - all text from all textboxes can be delivered to a final textbox on final page. If That is right the only thing left would be presentation of the text in the final textbox which I imagine is not to difficult to work out.


I have one last enquiry if you would be kind enough to enlighhten me:-

When approaching hosting providers do I need to make sure of anything specific re Session State - are there any pitfalls I should look out for? Can you reccommend a good value hoster which will run Session State efficiently.

I think I may be online by :xmas: providing my pages validate and publishing from VWD etc is not to difficult to learn.

Thanks again for your advice! :^: :)
Charlie
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2