473,399 Members | 2,146 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Generating event handler at run time.

mg
The following code runs without error, but the alert does not appear. Can you
see the problem?
private void LinkButton1_Click(object sender, System.EventArgs e)
{
System.Web.UI.WebControls.ImageButton ImageButton1 = new ImageButton();
ImageButton1.Height = 18;
ImageButton1.Width = 100;
ImageButton1.ImageUrl = @"\images\continue.gif";
Panel1.Controls.Add(ImageButton1);
ImageButton1.Click += new ImageClickEventHandler(ImageButton1_Click);
}
private void ImageButton1_Click(object sender, ImageClickEventArgs e)
{
Response.Write("<script language='javascript'>alert('TEST');</script>");
}

Nov 16 '05 #1
3 3151
mg
That is, the 'alert' does not appear when the ImageButton is clicked.

"mg" wrote:
The following code runs without error, but the alert does not appear. Can you
see the problem?
private void LinkButton1_Click(object sender, System.EventArgs e)
{
System.Web.UI.WebControls.ImageButton ImageButton1 = new ImageButton();
ImageButton1.Height = 18;
ImageButton1.Width = 100;
ImageButton1.ImageUrl = @"\images\continue.gif";
Panel1.Controls.Add(ImageButton1);
ImageButton1.Click += new ImageClickEventHandler(ImageButton1_Click);
}
private void ImageButton1_Click(object sender, ImageClickEventArgs e)
{
Response.Write("<script language='javascript'>alert('TEST');</script>");
}

Nov 16 '05 #2
Hi,

The problem is that you have to create the ImageButton and set the event
handler in OnInit or Page_Load event.

Regards,
Peter Jausovec
(http://blog.jausovec.net)

"mg" <mg@discussions.microsoft.com> je napisal v sporočilo
news:CE**********************************@microsof t.com ...
That is, the 'alert' does not appear when the ImageButton is clicked.

"mg" wrote:
The following code runs without error, but the alert does not appear. Can
you
see the problem?
private void LinkButton1_Click(object sender, System.EventArgs e)
{
System.Web.UI.WebControls.ImageButton ImageButton1 = new ImageButton();
ImageButton1.Height = 18;
ImageButton1.Width = 100;
ImageButton1.ImageUrl = @"\images\continue.gif";
Panel1.Controls.Add(ImageButton1);
ImageButton1.Click += new ImageClickEventHandler(ImageButton1_Click);
}
private void ImageButton1_Click(object sender, ImageClickEventArgs e)
{
Response.Write("<script language='javascript'>alert('TEST');</script>");
}

Nov 16 '05 #3
mg
You have been helpfull. Thank you.

"Peter Jausovec" wrote:
Hi,

The problem is that you have to create the ImageButton and set the event
handler in OnInit or Page_Load event.

Regards,
Peter Jausovec
(http://blog.jausovec.net)

"mg" <mg@discussions.microsoft.com> je napisal v sporoèilo
news:CE**********************************@microsof t.com ...
That is, the 'alert' does not appear when the ImageButton is clicked.

"mg" wrote:
The following code runs without error, but the alert does not appear. Can
you
see the problem?
private void LinkButton1_Click(object sender, System.EventArgs e)
{
System.Web.UI.WebControls.ImageButton ImageButton1 = new ImageButton();
ImageButton1.Height = 18;
ImageButton1.Width = 100;
ImageButton1.ImageUrl = @"\images\continue.gif";
Panel1.Controls.Add(ImageButton1);
ImageButton1.Click += new ImageClickEventHandler(ImageButton1_Click);
}
private void ImageButton1_Click(object sender, ImageClickEventArgs e)
{
Response.Write("<script language='javascript'>alert('TEST');</script>");
}


Nov 16 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: tony kulik | last post by:
This code works fine in ie and opera but not at all in Mozilla. Anybody got a clue as to how to get it right? <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <script...
8
by: Mark | last post by:
Hi, I'm looking for some ideas on how to build a very simple Event processing framework in my C++ app. Here is a quick background ... I'm building a multithreaded app in C++ (on Linux) that...
4
by: Lee Chapman | last post by:
Hi, I am having difficulty getting the ASP.NET framework to generate valid XHTML. My immediate problem surrounds user input in, for example, textbox controls. I consider characters such as...
2
by: Gary Brown | last post by:
Hi, I dynamically connect a MDI parent's toolstrip button to a child event handler by calling the following member at the child's Activated and Deactivate events. It looks simple enough but...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.