change style of  submit button on top and bottom of the page

Posted on 2011-10-18
Last Modified: 2012-05-12
I have a submit button on top and bottom of the page, when the user clicks on either button, I want to change the image on the button and disable both the buttons.

I have the code to do achieve this just on the buttons that were clicked. Please suggest how I can add the code for both the buttons to do the same. thanks

 ibtnPlaceOrder.Attributes.Add("onclick", _
                                "src='/Assets/Images/Checkout/PlaceOrder_Disabled.jpg'; this.disabled = true;" _
                                    + Page.ClientScript.GetPostBackEventReference(New PostBackOptions(ibtnPlaceOrder)))
                    ibtnPlaceOrderTop.Attributes.Add("onclick", _
                               "src='/Assets/Images/Checkout/PlaceOrder_Disabled.jpg'; this.disabled = true;" _
                                   + Page.ClientScript.GetPostBackEventReference(New PostBackOptions(ibtnPlaceOrderTop)))
Question by:TrialUser
    LVL 83

    Accepted Solution

    You need to add a function in javascript which disables both buttons and changes the image. Then call this function in the onclick above.
    LVL 12

    Assisted Solution

    by:Ramkisan Jagtap
    <script language="javascript" type="text/javascript">
       function ButtonOnClick()
            var btn1=document.getgetElementById("<%=Button1.ClientId%>");
            var btn2=document.getgetElementById("<%=Button2.ClientId%>");
          <asp:Button ID="Button1" runat="server" Text="Button"
                OnClientClick="ButtonOnClick()" onclick="Button_Click1"  />
          <asp:Button ID="Button2" runat="server" Text="Button" OnClientClick="ButtonOnClick()" onclick="Button_Click1" />

    Call ButtonOnClick() onClientClick which will disable your button and chnge the back ground image.
    Call Button_Click1 onClick Event Which will execute your server side code.

    Hope this will help you.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Maximize Your Threat Intelligence Reporting

    Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

    Suggested Solutions

    In Part 1 ( we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
    It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
    The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
    The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now