Quantcast
Channel: CodeProject Latest postings for ASP.NET
Viewing all articles
Browse latest Browse all 3938

Event not working with ParseControl method

$
0
0
I want to add dynamic image button on site without ID of Image button so I am using ASP tag to generate dynamic controls with ParseControl method, It's working but event is not fired when click on Image Button
 
Default.aspx.cs Code
protected void Page_Load(object sender, EventArgs e)
        {
            string str = @"<asp:ImageButton runat="server" ImageUrl=""~/close-icon (1).png"" OnClick=""click"" />";
            Control c = Page.ParseControl(str);
            form1.Controls.Add(c);
        }
 
        protected void click(object sender, ImageClickEventArgs e)
        {
            Response.Write("Image Clicl");
        }
Default.aspx Code
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication1._Default" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
 
    </div>
    </form>
</body>
</html>
 
Please help me to solve my problem by giving code in solution.

Viewing all articles
Browse latest Browse all 3938

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>