Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Reading a Textbox into an array

Reading a Textbox into an array

Scheduled Pinned Locked Moved ASP.NET
csharpdata-structures
12 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    Ibuprofen
    wrote on last edited by
    #1

    I have a textbox, that records the file names of upload files, and seperates it out with a , I would like to create an array that would read this text box, and seperate it out, so I can create a link for each file. I could really use some examples in code. My codebehind is C#

    T 1 Reply Last reply
    0
    • I Ibuprofen

      I have a textbox, that records the file names of upload files, and seperates it out with a , I would like to create an array that would read this text box, and seperate it out, so I can create a link for each file. I could really use some examples in code. My codebehind is C#

      T Offline
      T Offline
      Tarakeshwar Reddy
      wrote on last edited by
      #2

      string[] FileNames = txtFileNames.Text.Split(',');

      I 1 Reply Last reply
      0
      • T Tarakeshwar Reddy

        string[] FileNames = txtFileNames.Text.Split(',');

        I Offline
        I Offline
        Ibuprofen
        wrote on last edited by
        #3

        So then it will string as them as? like how do I assign each portion of the string a varible? Or am I not getting something as simple? Trying to figure out how I would link them.

        I T 2 Replies Last reply
        0
        • I Ibuprofen

          So then it will string as them as? like how do I assign each portion of the string a varible? Or am I not getting something as simple? Trying to figure out how I would link them.

          I Offline
          I Offline
          Ibuprofen
          wrote on last edited by
          #4

          Something like this no? string FileNames[1]=dr["HyperLink1"].ToString();

          1 Reply Last reply
          0
          • I Ibuprofen

            So then it will string as them as? like how do I assign each portion of the string a varible? Or am I not getting something as simple? Trying to figure out how I would link them.

            T Offline
            T Offline
            Tarakeshwar Reddy
            wrote on last edited by
            #5

            Put a placeholder control in the screen, read the filenames and dynamically add link buttons and the click event for each of the links.

            I 1 Reply Last reply
            0
            • T Tarakeshwar Reddy

              Put a placeholder control in the screen, read the filenames and dynamically add link buttons and the click event for each of the links.

              I Offline
              I Offline
              Ibuprofen
              wrote on last edited by
              #6

              If I understood any of this, I imagine I'd be in good shape. Pardon me, I've only been using .net for about 3 months before, that had never developed anything, and was given a full blown, huge ass project by my work, they know I can't code C# and I am still learning, they just elinated my job... I hate to be a pain in the ass, but could you explain a little further?

              T 1 Reply Last reply
              0
              • I Ibuprofen

                If I understood any of this, I imagine I'd be in good shape. Pardon me, I've only been using .net for about 3 months before, that had never developed anything, and was given a full blown, huge ass project by my work, they know I can't code C# and I am still learning, they just elinated my job... I hate to be a pain in the ass, but could you explain a little further?

                T Offline
                T Offline
                Tarakeshwar Reddy
                wrote on last edited by
                #7

                Have a look at this article[^] on codeproject, it shows you how to create dynamic controls. This msdn[^] shows you how to add controls to a place holder. In the click event of the button, split the filenames into an array, for every item in the array create a linkbutton with a click event and add it to the placeholder

                ex:
                LinkButton link;
                for(int i = 0; i <= FileNames.Length-1 ; i++)
                {
                link = new LinkButton();
                link.ID = "link"+i.ToString();
                link.Text = "http://www.yoursite.com/uploadedfile/"+ FileNames[i];
                link.Click += new EventHandler(link_Click);
                PlaceHolder1.Controls.Add(link);
                }

                Instead of the linkbutton you can also use the label control and set the text of the label control as Label1.Text = a href to pass the location to it. This is just a sample code, just change it to how you need it. You will have to ensure that the controls get added back when a postback takes place.

                Last modified: 16mins after originally posted --

                I 2 Replies Last reply
                0
                • T Tarakeshwar Reddy

                  Have a look at this article[^] on codeproject, it shows you how to create dynamic controls. This msdn[^] shows you how to add controls to a place holder. In the click event of the button, split the filenames into an array, for every item in the array create a linkbutton with a click event and add it to the placeholder

                  ex:
                  LinkButton link;
                  for(int i = 0; i <= FileNames.Length-1 ; i++)
                  {
                  link = new LinkButton();
                  link.ID = "link"+i.ToString();
                  link.Text = "http://www.yoursite.com/uploadedfile/"+ FileNames[i];
                  link.Click += new EventHandler(link_Click);
                  PlaceHolder1.Controls.Add(link);
                  }

                  Instead of the linkbutton you can also use the label control and set the text of the label control as Label1.Text = a href to pass the location to it. This is just a sample code, just change it to how you need it. You will have to ensure that the controls get added back when a postback takes place.

                  Last modified: 16mins after originally posted --

                  I Offline
                  I Offline
                  Ibuprofen
                  wrote on last edited by
                  #8

                  Thank you, and I am glad your willing to help such a newb like myself, but believe me, I am trying to help myself at the same time. Thanks for links to articles on this, will most definately read. I found some good help in my Visual C# .Net book as well.

                  1 Reply Last reply
                  0
                  • T Tarakeshwar Reddy

                    Have a look at this article[^] on codeproject, it shows you how to create dynamic controls. This msdn[^] shows you how to add controls to a place holder. In the click event of the button, split the filenames into an array, for every item in the array create a linkbutton with a click event and add it to the placeholder

                    ex:
                    LinkButton link;
                    for(int i = 0; i <= FileNames.Length-1 ; i++)
                    {
                    link = new LinkButton();
                    link.ID = "link"+i.ToString();
                    link.Text = "http://www.yoursite.com/uploadedfile/"+ FileNames[i];
                    link.Click += new EventHandler(link_Click);
                    PlaceHolder1.Controls.Add(link);
                    }

                    Instead of the linkbutton you can also use the label control and set the text of the label control as Label1.Text = a href to pass the location to it. This is just a sample code, just change it to how you need it. You will have to ensure that the controls get added back when a postback takes place.

                    Last modified: 16mins after originally posted --

                    I Offline
                    I Offline
                    Ibuprofen
                    wrote on last edited by
                    #9

                    Both links went to code project

                    T 1 Reply Last reply
                    0
                    • I Ibuprofen

                      Both links went to code project

                      T Offline
                      T Offline
                      Tarakeshwar Reddy
                      wrote on last edited by
                      #10

                      Sorry. I Have changed it now, have a look.

                      I 1 Reply Last reply
                      0
                      • T Tarakeshwar Reddy

                        Sorry. I Have changed it now, have a look.

                        I Offline
                        I Offline
                        Ibuprofen
                        wrote on last edited by
                        #11

                        This is going to be great for my upload on my main form that they upload on, but for the page I am doing this on, its just to view, they will not be allowed to upload any files, just vewing files attached to a helpdesk record.

                        T 1 Reply Last reply
                        0
                        • I Ibuprofen

                          This is going to be great for my upload on my main form that they upload on, but for the page I am doing this on, its just to view, they will not be allowed to upload any files, just vewing files attached to a helpdesk record.

                          T Offline
                          T Offline
                          Tarakeshwar Reddy
                          wrote on last edited by
                          #12

                          Just pass the string to the required page or store it and retrieve it from some location and do the same thing.

                          1 Reply Last reply
                          0
                          Reply
                          • Reply as topic
                          Log in to reply
                          • Oldest to Newest
                          • Newest to Oldest
                          • Most Votes


                          • Login

                          • Don't have an account? Register

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • World
                          • Users
                          • Groups