Follow by Email

Saturday, August 2, 2014

call codebehind method from controls like label to return a value

hi in this post i will show how to call a code-behind method from control. here i will be taking example with label.

Example :

Aspx page :

<html xmlns="">
<head runat="server">
    <form id="form1" runat="server">
   <asp:Label ID="Label1" runat="server"><%= GetName(" Singh") %></asp:Label>

Code behind :

  protected string GetName(string input)
        return "Chandan" + HttpUtility.HtmlEncode(input);