I wrote like this
for loop
{
ImageButton btn = new ImageButton();
btn.ID = "btn" + i;
btn.ImageUrl = "images/edit.jpg";
//btn.OnClientClick += new EventHandler(get);
btn.Attributes.Add("onclick", "get()");
}
public void get(object sender, EventArgs e)
{
this.mopopupeditrule.Show();
}in this onclick function not works..how can i give...if i click button one modalpopup want to show..any idea?
anjumathi kumarPosted Aug 3, 2011, 4:54 AM
public void addimage()
{
for loop
{
ImageButton btn1 = new ImageButton();
btn1.ID = "btn1" + i;
btn1.Click +=
btn1.ImageUrl =new ImageClickEventHandler(get);"images/edit.jpg";
}
}
public void get(object sender, EventArgs e){
mopopupeditrule.Show();//this my ajax control modalpopup
but if i click the image button the
modalpopupwant to show..but it
does not work kile i given above
}
Priya LingePosted Aug 3, 2011, 4:13 AM
By following way you call script funtion at clientside.
private void Button1_Click(object sender, System.EventArgs e)
{
string javaScript =
"";
RegisterStartupScript("Button1_ClickScript", javaScript);
}
Thanks.
Priya LingePosted Aug 3, 2011, 3:42 AM
You used the imageButton, imageButton has ImageClickEventHandler.
for (int i = 0; i < 4; i++)
{
ImageButton btn1 = new ImageButton();
btn1.Click += new ImageClickEventHandler(get);
//Button btn = new Button();
btn1.ID = "btn" + i;
btn1.Height = 20;
btn1.Width = 50;
//btn.OnClientClick = "get()";
Panel1.Controls.Add(btn1);
}
}
public void get(object sender, ImageClickEventArgs e)
{
MessageBox.Show("hi");
}
Thanks.
anjumathi kumarPosted Aug 3, 2011, 3:39 AM
here how can i add this in clientside
anjumathi kumarPosted Aug 3, 2011, 3:29 AM
btn1.Click +=
new EventHandler(get);here get showing error..cannot implicictly convert system.eventhandler into imageclick eventhandler
how to solve
Priya LingePosted Aug 3, 2011, 3:18 AM
Please try this.
protected void Page_Load(object sender, EventArgs e)
{
for (int i = 0; i < 4; i++)
{
Button btn = new Button();
btn.Text = "Button " + i;
btn.Height = 20;
btn.Width = 50;
btn.OnClientClick = "get()";
Panel1.Controls.Add(btn);
}
}
Hope this will help you.
Thanks.