Free programming examples and instructions

Calling serverside function from html button

Demo and code for calling c# function from html button. How to use font awsome in asp

by Athil

Posted on 12 Feb 2017 Category: Asp.net Views: 3218

Edited on 25 Jul 2018

Asp buttons have some limitations for design, We cannot use font awesome design, image as background etc for asp buttons. So use html buttons for design is goog option for design and add a runat attribute with value  "server"

For calling server side click event from html button, need to add onserverclick attribute in button tag.


Eg:-   <button id="btn1" runat="server" onserverclick ="ServerSide"> HTML </button>

From Client Side

  <form id="form1" runat="server">
    <button style="font-size:24px" runat="server" onserverclick ="ServerSide">Button <i class="fa fa-arrows-alt"></i></button>


From Server Side


   public void ServerSide(object s, EventArgs e)
            Response.Write("From html Button");


Leave a Comment: