UncleCoder.com

UncleCoder.com

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: 2960

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.

DEMO

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

From Client Side

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

 

From Server Side

 

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

 



Leave a Comment:


Advertisement