Showing posts with label save. Show all posts
Showing posts with label save. Show all posts

Thursday, March 29, 2012

Newbie: How to upload and save images using ASP.NET web forms (C#)

Hello -

I need to upload images in my web application using ASP.NET web forms
(written in C#). Since i have never done this before, i am unsure what is the
best method.

I assume there are two options:

1). Upload the images and save the files directory to the windows file
system. However, i assume this poses a security risk, as the file directory
will require write permissions.

2). Save the images (as objects?) in the SQL SERVER database.

Can anyone suggest the best way to do this? And, if possible, point me to
some sample code or artciles which explain how to do this.

Thanks!Charlie,

check out the following article:

http://www.codeproject.com/aspnet/fileupload.asp

I prefer to save files in the database but it depends on your needs.

If you need to save hundred thousands of files and decide that you want to
save them on your hard disk make sure to distribute them on different
directories. What you could do is that you assign a guid to each file and
create your directory structure accordingly.

Example:

You have five files with the following guids

0A59E8D6-0AE5-475B-8698-814C2C712029

F16CE1B1-56D0-42E6-9463-A58D553CC289

D90C27C7 -8BD9-4F47-8CFE-DE9D240AD136

370B6080-DF06-4DDE-BB5E-85264B8AE48B

861DC387-FDC7-4A4F-B0C3-9EA6734A562A

You could now create a directory like the following:

0A59E8D6\0AE5\475B\8698\814C2C712029

F16CE1B1\56D0\42E6\9463\A58D553CC289

D90C27C7 \8BD9\4F47\8CFE\DE9D240AD136

370B6080\DF06\4DDE\BB5E\85264B8AE48B

861DC387\FDC7\4A4F\B0C3\9EA6734A562A

HTHs

Daniel

"charliewest" <charliewest@.discussions.microsoft.com> schrieb im Newsbeitrag
news:E6DD7087-DC4F-4E78-9741-0EF7F76883B6@.microsoft.com...
> Hello -
> I need to upload images in my web application using ASP.NET web forms
> (written in C#). Since i have never done this before, i am unsure what is
> the
> best method.
> I assume there are two options:
> 1). Upload the images and save the files directory to the windows file
> system. However, i assume this poses a security risk, as the file
> directory
> will require write permissions.
> 2). Save the images (as objects?) in the SQL SERVER database.
> Can anyone suggest the best way to do this? And, if possible, point me to
> some sample code or artciles which explain how to do this.
> Thanks!

Saturday, March 24, 2012

Newbie: Save and display multi-value listbox... (VB.NET)

I have a list box (i.e. FieldA) that allows the user to select more than one option. When saved, this field content is inserted in a table.

My questions are:
- How do i loop through this listbox and save the data. Do i need to concatenate the selected options into a string before or during saving?
- When this saved record is retrieved from the table, do i need to do anything in order to display the options that have previously been selected and saved?
I appreciate any coding that you can provide to assist me...

Try this article, it was helpful to me when I dealt with this same issue.
http://www.developerfusion.co.uk/show/4653/

Thursday, March 22, 2012

Newbiew use of DropDownList.

Hi,
I think this is the first time I put a dropdownlist in a web form, it
correctly displays the values from the database and when I save the
form I'm able to save the corresponding value to the database. But when
I use the form to display data, the listbox does not automatically
display the value saved in the database of course, so how am I supposed
to make point to the saved value ?Hi,
You can do it one of two ways.
(after ddl is populated)
DropDownList.SelectedIndex =
DropDownList.Items.IndexOf(DropDownList.Items.FindByText(MyDataReader("Field
Name")))
or
(if before ddl is populated)
DropDownList.DataTextField=MyDataReader("FieldName")
I hope this helps.
Mike Douglas
On 26 Mar 2005 16:17:20 -0800, craigkenisston@.hotmail.com wrote:

>Hi,
>I think this is the first time I put a dropdownlist in a web form, it
>correctly displays the values from the database and when I save the
>form I'm able to save the corresponding value to the database. But when
>I use the form to display data, the listbox does not automatically
>display the value saved in the database of course, so how am I supposed
>to make point to the saved value ?

Newbiew use of DropDownList.

Hi,

I think this is the first time I put a dropdownlist in a web form, it
correctly displays the values from the database and when I save the
form I'm able to save the corresponding value to the database. But when
I use the form to display data, the listbox does not automatically
display the value saved in the database of course, so how am I supposed
to make point to the saved value ?Hi,

You can do it one of two ways.

(after ddl is populated)
DropDownList.SelectedIndex =
DropDownList.Items.IndexOf(DropDownList.Items.Find ByText(MyDataReader("FieldName")))

or

(if before ddl is populated)
DropDownList.DataTextField=MyDataReader("FieldName")

I hope this helps.

Mike Douglas

On 26 Mar 2005 16:17:20 -0800, craigkenisston@.hotmail.com wrote:

>Hi,
>I think this is the first time I put a dropdownlist in a web form, it
>correctly displays the values from the database and when I save the
>form I'm able to save the corresponding value to the database. But when
>I use the form to display data, the listbox does not automatically
>display the value saved in the database of course, so how am I supposed
>to make point to the saved value ?