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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T16:56:06+00:00 2026-06-14T16:56:06+00:00

I have asp button: <asp:button ID=btn1 runat=server CommandArgument= CssClass=btn1 OnClick=button_click></asp:button> and script: $(a).click(function ()

  • 0

I have asp button:

<asp:button ID="btn1" runat="server" CommandArgument="" CssClass="btn1" OnClick="button_click"></asp:button>

and script:

$("a").click(function () {
            var val = $(this).attr('id').toString();                            
            $('.btn1').attr('CommandArgument',val);
            alert($('.btn1').attr('CommandArgument').toString());
            $('.btn1').click();
        });

after click it alerts me command argument. But on next step – when i trigger btn1 click with jquery it goes to codebehind and command argument is empty. Can i pass somehow command argument with jquery?

I’ve tried to save value to global variables but after postback they’re all empty. And i don’t want to use cookies or viewstate for that.

Thanks!

  • 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-14T16:56:08+00:00Added an answer on June 14, 2026 at 4:56 pm

    CommandArgument is completely a server-side property and doesn’t render any html attribute. So you can’t change any button’s attribute and fire click on it. The good news is that you can fire postback with client-side __doPostBack function and pass your custom value as second parameter:

    <script type="text/javascript">
        $("a").click(function () {
            var val = $(this).attr('id').toString();
            __doPostBack("<%= btn1.UniqueID %>", val);
        });
    </script>
    

    And you can get passed argument in server click handler from the Request.Form collection:

    protected void button_click(object sender, EventArgs e)
    {
        var argument = Request.Form["__EVENTARGUMENT"];
    }
    

    If script above won’t work then maybe __doPostBack function not defined on page. In this case add this code to Page_PreRender method: ClientScript.GetPostBackEventReference(btn1, string.Empty); this will force page to define __doPostBack method on page.

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

Sidebar

Related Questions

I have this ASP.net component: <asp:Button ID=Button4 runat=server Text=Submit Entry CssClass=eventSubmitButton OnClick=SubmitData/> and I'd
I have an asp.net button to update database <asp:Button ID=btnSave runat=server Text=SaveChanges OnClick=btnSave_Click CssClass=saveButton
i have asp button like this: <asp:Button ID=ImportToDB runat=server OnClick=ImportToDB_Click /> And i need
i have asp text box and button control. <asp:TextBox ID=txtFName runat=server CssClass=sfInputbox></asp:TextBox> <asp:Button runat=Server
I have a Image button defined as follow, <div> <asp:ImageButton ID=btn1 runat=server ImageUrl=/_LAYOUTS/1033/IMAGES/row.png />
If I have this asp.net button: <asp:Button ID=Button_Save Width=150px OnClick=Button_Save_Click runat=server Text=Save /> In
I have two button as shown below: 1st Button: <asp:Button ID=btn1 runat=server Text=First Button
I have a asp:UpdatePanel with a asp:Button and a asp:TextBox : <asp:UpdatePanel ID=UpdatePanel1 runat=server>
I have code below: <select id=testSelect> <option value=1>One</option> <option value=2>Two</option> </select> <asp:Button ID=btnTest runat=server
I have an Asp server control button for which I have onClick for processing

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.