Reading a Textbox into an array
-
string[] FileNames = txtFileNames.Text.Split(',');
-
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.
-
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.
Put a placeholder control in the screen, read the filenames and dynamically add link buttons and the click event for each of the links.
-
Put a placeholder control in the screen, read the filenames and dynamically add link buttons and the click event for each of the links.
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?
-
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?
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 --
-
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 --
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.
-
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 --
-
Sorry. I Have changed it now, have a look.
-
Sorry. I Have changed it now, have a look.
-
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.
Just pass the string to the required page or store it and retrieve it from some location and do the same thing.