Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9009003
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T02:05:12+00:00 2026-06-16T02:05:12+00:00

On Button Click Protected Sub btnSubmit_Click(sender As Object, e As System.EventArgs) Handles btnSubmit.Click MsgBox(INSIDE)

  • 0

On Button Click

Protected Sub btnSubmit_Click(sender As Object, e As System.EventArgs) Handles btnSubmit.Click
        MsgBox("INSIDE")
        If SocialAuthUser.IsLoggedIn Then
            Dim accountId As Integer = BLL.getAccIDFromSocialAuthSession
            Dim AlbumID As Integer = BLL.createAndReturnNewAlbumId(txtStoryTitle.Text.Trim, "")
            Dim URL As String = BLL.getAlbumPicUrl(txtStoryTitle.Text.Trim)
            Dim dt As New DataTable
            dt.Columns.Add("PictureID")
            dt.Columns.Add("AccountID")
            dt.Columns.Add("AlbumID")
            dt.Columns.Add("URL")
            dt.Columns.Add("Thumbnail")
            dt.Columns.Add("Description")
            dt.Columns.Add("AlbumCover")
            dt.Columns.Add("Tags")
            dt.Columns.Add("Votes")
            dt.Columns.Add("Abused")
            dt.Columns.Add("isActive")
            Dim Row As DataRow

            Dim uniqueFileName As String = ""
            If Session("ID") Is Nothing Then
                lblMessage.Text = "You don't seem to have uploaded any pictures."
                Exit Sub
            Else


**Dim FileCount As Integer = Request.Form(Request.Form.Count - 2)**
                Dim FileName, TargetName As String
                Try
                    Dim Path As String = Server.MapPath(BLL.getAlbumPicUrl(txtStoryTitle.Text.Trim))
                    If Not IO.Directory.Exists(Path) Then
                        IO.Directory.CreateDirectory(Path)
                    End If
                    Dim StartIndex As Integer
                    Dim PicCount As Integer
                    For i As Integer = 0 To Request.Form.Count - 1
                        If Request.Form(i).ToLower.Contains("jpg") Or Request.Form(i).ToLower.Contains("gif") Or Request.Form(i).ToLower.Contains("png") Then
                            StartIndex = i + 1
                            Exit For
                        End If
                    Next
                    For i As Integer = StartIndex To Request.Form.Count - 4 Step 3
                        FileName = Request.Form(i)
                        '## If part here is not kaam ka..but still using it for worst case scenario
                        If IO.File.Exists(Path & FileName) Then
                            TargetName = Path & FileName
                            'MsgBox(TargetName & "--- 1")
                            Dim j As Integer = 1
                            While IO.File.Exists(TargetName)
                                TargetName = Path & IO.Path.GetFileNameWithoutExtension(FileName) & "(" & j & ")" & IO.Path.GetExtension(FileName)
                                j += 1
                            End While
                        Else
                            uniqueFileName = Guid.NewGuid.ToString & "__" & FileName
                            TargetName = Path & uniqueFileName

                        End If
                        IO.File.Move(Server.MapPath("~/TempUploads/" & Session("ID") & "/" & FileName), TargetName)
                        PicCount += 1
                        Row = dt.NewRow()
                        Row(1) = accountId
                        Row(2) = AlbumID
                        Row(3) = URL & uniqueFileName
                        Row(4) = ""
                        Row(5) = "No Desc"
                        Row(6) = "False"
                        Row(7) = ""
                        Row(8) = "0"
                        Row(9) = "0"
                        Row(10) = "True"
                        dt.Rows.Add(Row)
                    Next
                    If BLL.insertImagesIntoAlbum(dt) Then

                        lblMessage.Text = PicCount & IIf(PicCount = 1, " Picture", " Pictures") & " Saved!"
                        lblMessage.ForeColor = Drawing.Color.Black
                        Dim db As SqlDatabase = Connection.connection
                        Using cmd As DbCommand = db.GetSqlStringCommand("SELECT PictureID,URL FROM AlbumPictures WHERE AlbumID=@AlbumID AND AccountID=@AccountID")
                            db.AddInParameter(cmd, "AlbumID", Data.DbType.Int32, AlbumID)
                            db.AddInParameter(cmd, "AccountID", Data.DbType.Int32, accountId)
                            Using ds As DataSet = db.ExecuteDataSet(cmd)
                                If ds.Tables(0).Rows.Count > 0 Then
                                    ListView1.DataSource = ds.Tables(0)
                                    ListView1.DataBind()
                                Else
                                    lblMessage.Text = "No Such Album Exists."
                                End If

                            End Using
                        End Using
                        'WebNavigator.GoToResponseRedirect(WebNavigator.URLFor.ReturnUrl("~/Memories/SortImages.aspx?id=" & AlbumID))
                    Else
                        'TODO:we'll show some error msg
                    End If

                Catch ex As Exception
                    MsgBox(ex.Message)
                    lblMessage.Text = "Oo Poop!!"
                End Try
            End If
        Else
            WebNavigator.GoToResponseRedirect(WebNavigator.URLFor.LoginWithReturnUrl("~/Memories/CreateAlbum.aspx"))
            Exit Sub
        End If

    End Sub

The above code works fine.I have added an Update Panel in the page to avoid post back, But when i add the button click as a trigger

<Triggers>
   <asp:AsyncPostBackTrigger ControlID="btnSubmit" />
</Triggers>

in the update panel to avoid post back, i get the following error.This happens when i add the button click as a Trigger to the update panel.

enter image description here

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T02:05:14+00:00Added an answer on June 16, 2026 at 2:05 am

    The Request.Form returns a NameValueCollection which is accessible by the name of the key or the int indexer. It always returns a String and not an Integer.

    Dim FileCount As String = Request.Form(Request.Form.Count - 2)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Code for button: Protected Sub btnAdd_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click Dim s
codebehind Protected Sub btnDelete_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnDelete.Click Dim
Protected Sub btnDelete_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnDelete.Click Dim ResourceObject
Here is the code for the button click event; Protected Sub CompetenciesButton_Click(ByVal sender As
protected void Button1_Click(object sender, EventArgs e) { System.Collections.ArrayList list = new System.Collections.ArrayList(); list.Add(abc); list.Add(xyz);
I am using VB.NET and below code on button click event. Protected Sub ibtnSendInvites_Click(ByVal
protected void Button3_Click(object sender, EventArgs e) //export { GridView2.AllowPaging = false; GridViewExportUtil.Export(Сводка.xls, this.GridView2); GridView2.AllowPaging
I use this code in my VB.Net application Protected Sub btnBHNas_Click(ByVal sender As Object,
Time to learn some basics. Look at the code below: protected void Button1_Click(object sender,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.