Beginner need help. Ajax control tools.

10e5x

Member
Joined
Jun 29, 2012
Messages
14
Programming Experience
Beginner
Hi, i am new to vb and just started exploring vs2010 and ajax. I am trying to achieve:

1) allowing user to upload an image file using ajax (should i use AjaxFIleUpload or AsyncFileUpload)
2) able to validate the file whether is it an image file (achieved)
3) no matter what size they choose to upload i will be able to resize to the size i wanted(achieved)
4) able to save the imagefilepath inside my database so i will be able to display it dynamically at another aspx. (stucked not achieved)

I am using the AsyncFileUpload currently as i do not know the difference. I am doing this for my sch proj wanting to create a user and display the user profile. Greatly appreciate your help. Thanks
 

Dunfiddlin

Well-known member
Joined
Jun 15, 2012
Messages
253
Programming Experience
5-10
AjaxFileUpload is for multiple files and has extended properties accordingly. Async is fine for your needs.

We'll need to see your code for the remaining problem.
 

10e5x

Member
Joined
Jun 29, 2012
Messages
14
Programming Experience
Beginner
AjaxFileUpload is for multiple files and has extended properties accordingly. Async is fine for your needs.

We'll need to see your code for the remaining problem.

aspx.vb file:
Imports AjaxControlToolkit
Imports System.IO
Imports System.Data.SqlClient
Imports System.Data

Partial Class upload
    Inherits System.Web.UI.Page

    Protected Sub Button12_Click(sender As Object, e As System.EventArgs) Handles Button12.Click

        Dim filename As String = System.IO.Path.GetFileName(AsyncFileUpload1.PostedFile.FileName)

        AsyncFileUpload1.SaveAs(Server.MapPath("Img/" + filename))

        Dim con As New SqlConnection(ConfigurationManager.ConnectionStrings("SilverHeartConnectionString").ToString())

        con.Open()

        Dim cmd As New SqlCommand("Insert into NHadv(nhImgFilePath) values(@nhImgFilePath)", con)

        cmd.Parameters.AddWithValue("@nhImgFilePath", filename)

        'executing the query
        Command.ExecuteNonQuery()

        con.Close()
    End Sub
End Class

 
Last edited:

jmcilhinney

VB.NET Forum Moderator
Staff member
Joined
Aug 17, 2004
Messages
14,348
Location
Sydney, Australia
Programming Experience
10+
When someone asks you to "post your code", what they actually mean is "post the relevant code". There's a lot of code there and, while I could be wrong, I doubt that it's all relevant to the issue. If you post too much code then it means that either we have to spend our time narrowing down the problem where that is really your responsibility, or that we may just ignore it and you miss out on the help you need.

Also, I have added the appropriate formatting tags to make your code readable. Please do so for us in future.
 
Top Bottom