Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
See more: ASP.NET C#4.0
I have created link button in my application now i have binded the event handler to it but its not Firing any suggestion.
Posted 18-Oct-12 1:55am
aspnet_regiis -i at 18-Oct-12 7:05am
"not Firing any suggestion" ..How can it fire a suggestion ?
adriancs at 18-Oct-12 8:10am
I think that simply a grammar mistake and the sentences sounds to be like this:
......but its not Firing. Any suggestion?
AshishChaudha at 18-Oct-12 7:06am
share your code please..
adriancs at 18-Oct-12 8:11am
how do you "bind the event handler"?
aspnet_regiis -i at 18-Oct-12 9:51am
using += operator...
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

First Add Your link Button and Div message in .ASPX
<asp:LinkButton ID="ancDelete" CommandName="delete" OnCommand="delete_EventCategories" runat="server">Delete </asp:LinkButton>
<div id="divMessage" runat="server" class="grid_7 alpha" style="display: none;">
        <asp:Literal runat="server" ID="ltlMessage" Text="test"></asp:Literal>
Then write a Show method.
public static void ShowMessage(string _class, string msg, System.Web.UI.HtmlControls.HtmlGenericControl divMessage, Literal ltlMessage)
           divMessage.Style.Add("display", "block");
           divMessage.Attributes.Add("class", _class);
           ltlMessage.Text = msg;
And finally Event Hadelers.
protected void delete_EventCategories(object Sender, CommandEventArgs e)
            if (e.CommandName == "delete")
             ShowMessage("alert alert-success", " Successfully!",divMessage, ltlMessage);
                catch (Exception ex)
                  ShowMessage("alert alert-error", ex.InnerException.Message, divMessage,ltlMessage);
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

If it is matter of dynamic link control then just mind it that its state not persist my framework with the help of view state. For example if you create a link button like as follows
<div id="divLink"  runat="server">
if (!base.IsPostBack)//comment out this condition if you want to fire Click event 
    var control = new LinkButton();
    control.Text = "Clik ME";           
    control.Click += control_Click;
void control_Click(object sender, EventArgs e)
You see that next postback event the LinkButton not showing and event not firing.
If you want to fire that event you need to create that dynamic control every request (either postback or not postback.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 645
1 Maciej Los 225
2 Abhinav S 171
3 Richard Deeming 160
4 Suvendu Shekhar Giri 159
0 Sergey Alexandrovich Kryukov 9,623
1 OriginalGriff 9,135
2 Peter Leow 5,042
3 Kornfeld Eliyahu Peter 3,373
4 Maciej Los 2,581

Advertise | Privacy | Mobile
Web01 | 2.8.150327.1 | Last Updated 24 Feb 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100