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 6748055
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:31:10+00:00 2026-05-26T12:31:10+00:00

I have a button on a web page that when clicked connects to my

  • 0

I have a button on a web page that when clicked connects to my SQL server and runs a stored procedure. The buttons works fine (It simply pushes data into a database table).

I’m new to .NET programming and I’m having trouble finding the right code ideas to add on to the current code for the button I already have.

Ideally, I would just like to have a message box to appear when the button is clicked to notify the user that the ‘data has been saved’ with just the “OK” option and for the user to then be redirected to the home page.

I also need to make sure that this button is only pressed once or deactivated once it has been pressed that day as I don’t want the user to press the button multiple times.

Here is my current code for the button:

Protected Sub btnAddRawData_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnAddRawData.Click

    'database conn, this is linked to the web config file .AppSettings
    Using dbconnection As New SqlConnection(ConfigurationManager.AppSettings("dbconnection"))
        dbconnection.Open()

        'command to state the stored procedure and the name of the stored procedure
        Using dbcommand As SqlCommand = dbconnection.CreateCommand
            With dbcommand
                .CommandType = CommandType.StoredProcedure
                .CommandText = "GasNominationsRawData_Insert"

                'simply execute the query
                dbcommand.ExecuteNonQuery()

                'I need to add some code for the button here and...

                'redirect to the main home page
                Response.Redirect("~/default.aspx?")

            End With
        End Using
    End Using
End Sub

Any ideas and suggestions would be much appreciated.

Regards,
Betty.

  • 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-05-26T12:31:11+00:00Added an answer on May 26, 2026 at 12:31 pm
    function success()
    {
    
     alert('Your data has been saved successfully)';
     window.location.href='Default.aspx';
    }
    

    On code behind, right after this line:

    dbcommand.ExecuteNonQuery()
    

    Do this:

    Dim cs As ClientScriptManager = Page.ClientScript
    Dim csname1 As [String] = "PopupScript"
    Dim cstype As Type = Me.[GetType]()
    Dim cstext1 As New StringBuilder()
    cstext1.Append("success();")
    cs.RegisterStartupScript(cstype, csname1, cstext1.ToString())
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a web page that has a button that when clicked will download
On my web page I have a button that opens a modal jQuery dialog.
In a web page I have a button when clicked it calls a JavaScript
Here's the scenario: I have a textbox and a button on a web page.
I have a standard ASP.NET 2.0 web page with a Delete button on it.
I have a web form that has 2 radio buttons, depending on which one
I've got a web page with a button that opens another window. When the
I have a web page that sends email to multiple users (online distribution list).
I have a web page with some embedded Silverlight. In that Silverlight I have
I have web form in which I have to make sure that 'SUBMIT' button

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.