Create Alphabetic control and fetch its value on click in Asp.net c#
Create Alphabetic control and fetch its value on click in Asp.net c#
Step 1:Desgin web form .aspx page
<form id="form1" runat="server">
<div>
<asp:Panel ID="pnlAlphabate"
runat="server"
Style="border-color: Black; border-width: 1px;
border-style: solid; width: 200px; margin-bottom: 20px;">
</asp:Panel>
</div>
</form>
Step 2:Logic on .Cs page
protected void Page_Load(object sender, EventArgs
e)
{
string str = "A, B,
C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z,
ALL";
string[] spt = str.Split(',');
foreach (string
strAccountId in spt)
{
if (strAccountId.Trim() != string.Empty)
{
LinkButton lnkButton = new LinkButton();
lnkButton.Text = strAccountId;
lnkButton.ID = "lnkId" +
strAccountId;
lnkButton.Attributes.CssStyle.Add("text-decoration",
"none");
lnkButton.Click += new EventHandler(lnkButton_Click);
pnlAlphabate.Controls.Add(lnkButton);
}
}
}
void lnkButton_Click(object
sender, EventArgs e)
{
string str = ((System.Web.UI.WebControls.LinkButton)(sender)).Text;
Response.Write(str);
}
Comments
Post a Comment