• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 318
  • Last Modified:

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

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)))
2 Solutions
You need to add a function in javascript which disables both buttons and changes the image. Then call this function in the onclick above.
Ramkisan JagtapLead DeveloperCommented:
<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.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now