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

  • SEARCH
  • Home
  • 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 8103441
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T23:33:04+00:00 2026-06-05T23:33:04+00:00

this is a post back problem (I don’t want to use the client side

  • 0

this is a post back problem (I don’t want to use the client side to solve this issue , there must be a way to prevent the postBack then using the client side ) , i have a button when clicked it calls a javascript function from the code behind , but before it does this it post back the page , Question is : how can i skip the post back step and jump to the javascript part ??

<script type="text/javascript">
    function hello(name) {
        alert("hello world from javascript " + name)
        return false;
    }
</script>
 </head>
 <body>
<form id="form1" runat="server">
<div>
    <asp:Button ID="Button1" runat="server" Text="Button" />
</div>
</form>

code Behind :

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
    Dim Myname As String = "myName"
    Dim cstype As Type = Me.GetType()
    Page.ClientScript.RegisterStartupScript(cstype, "MyKey", "hello('" & Myname & "');", True)

End Sub
  • 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-05T23:33:05+00:00Added an answer on June 5, 2026 at 11:33 pm

    Use a client side handler instead of a server side handler. Remove Button1_Click and add your js call as an OnClientClick attribute value.

    <asp:Button ID="Button1" runat="server" Text="Button" 
                OnClientClick="return hello('myName');" />
    

    Or, don’t use a server control at all:

    <button id="button1" onclick="return hello('myName');">Button</button>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to forms and post data ... so I don't know how solve
Using the distance logic from this SO post , I'm getting back a properly-filtered
On this post MongoDB finding nested elements , author claims that the mongodb document
I have this flow but don't know how to deal with it. I think
I just want to know how to back up data From MYSQL database and
The code below has a link to cause a post back (asynchronous or not)
I am aware of this other post , but it doesn't seem to apply
Just when I was about to post this question, I came up with an
Can't get my head around this Jquery problem I have.. I've been looking around
I am using this code if form.is_valid(): form.save() if request.POST.get('ajax') == 'true': return HttpResponse('Data

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.