Click here to Skip to main content
15,879,095 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
My Code-:
C#
StringBuilder sb = new StringBuilder();
ImageButton imgBtn = new ImageButton();
imgBtn.ID = "imgBtn";
imgBtn.ImageUrl = "images/bestoffer.gif";
imgBtn.Click += new ImageClickEventHandler(imgBtn_Click);
imgBtn.Attributes.Add("style", "border-width: 0px;");
//this.Form.Controls.AddAt(1, imgBtn);
PlaceHolder1.Controls.Add(imgBtn);
sb.Append(imgBtn);

C#
protected void imgBtn_Click(object sender, ImageClickEventArgs e)
    {
        Session["place"] = "BestOffers";
        Session["location"] = null;
        Response.Redirect("listing.aspx");
    }


In this imgBtn_Click not event fire why?

so, please help me and solve this problem.
Posted
Updated 30-Jul-14 1:37am
v2

1 solution

I am not sure where you are generating your button. You should add your button to the page in the page's OnInit [^] event and wire up it's click event during or before OnLoad

Good luck.
 
Share this answer
 
v2
Comments
abhishek burnwal Kolkata 30-Jul-14 8:02am    
Image Button bind in string builder(dynamic control) then after that imagebutton click event.

My issue is onlickevent not working.
Raje_ 30-Jul-14 8:16am    
Where have you written first code segment?

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900