hi in this post i will show how to call a code-behind method from asp.net control. here i will be taking example with label.
Example :
Aspx page :
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="Label1" runat="server"><%= GetName(" Singh") %></asp:Label>
</div>
</form>
</body>
</html>
Code behind :
protected string GetName(string input)
{
return "Chandan" + HttpUtility.HtmlEncode(input);
}
}
Example :
Aspx page :
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="Label1" runat="server"><%= GetName(" Singh") %></asp:Label>
</div>
</form>
</body>
</html>
Code behind :
protected string GetName(string input)
{
return "Chandan" + HttpUtility.HtmlEncode(input);
}
}
Output:
No comments:
Post a Comment