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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T10:12:11+00:00 2026-05-16T10:12:11+00:00

I have an asp button (the code is below). I have the event handler

  • 0

I have an asp button (the code is below). I have the event handler working, but I want to pass a string (which is the result of a javascript function) into the event handler function. Is there a way to do that?

<asp:Button runat="server" ID="Button1"  OnClick="Button1_Click" Text="Run" />
  • 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-16T10:12:11+00:00Added an answer on May 16, 2026 at 10:12 am

    Normally the way you would do this is to have you javascript modify an input control so that the value will be posted back with the Button click. If you want the user to visually not be able see the data that your javascript is modifying to post back then you can write it to a HiddenField.

    You can use the OnClientClick to setup the javascript to run before the postback happens to ensure your modified value is put into the input control. Eg:

    <asp:Button ID="yourButton" runat="server" Text="Click Me!"
        OnClientClick="YourFunctionToAddStringToControl(); return true;"
        OnClick="yourButton_Click" />
    

    So you just need to swap the call to YourFunctionToAddStringToControl with your modified javascript function that is writing the value to a HiddenField or another input control. Then update your server side click handler to access the field.

    Side Note: When using javascript to write to server side controls such as HiddenField, don’t forget to use <%= yourHiddenField.ClientID %> to get the correct control name.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 533k
  • Answers 533k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer OK I got what I wanted from these links: http://www.notesfor.net/post/2009/01/21/Enhance-SharePoint-rich-text-field.aspx… May 17, 2026 at 12:34 am
  • Editorial Team
    Editorial Team added an answer Writing a server is a good real-world test of parallel… May 17, 2026 at 12:34 am
  • Editorial Team
    Editorial Team added an answer Is there currently API hooks in the iOS and Android… May 17, 2026 at 12:34 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I have the javascript code below which disables an asp.net button during page postback.
I have below HTML code <table class=innerGridTable cellpadding=0 cellspacing=0 width=100%> <tr id=trMain> <td> <asp:Button
I have ASP.Net code generating my button's HTML for me using divs to get
I am working in ASP .net 2.0. I am a learner. I have a
i have a strange problem only in Chrome using an iframe but working in
I have some code like below in an aspx page: function CheckEditing() { var
I have an issue that appears in all browsers. I am working with ASP.NET
I have created a custom web control to act as a button with an
I'm trying to create Command Buttons dynamically, but clicking the button in question doesn't
I have an ASP.NET page using the AJAX control toolkit for some controls. A

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.