Click here to Skip to main content
16,006,362 members
Home / Discussions / ASP.NET
   

ASP.NET

 
QuestionHow to Pass multiple arugumnets Pin
VenkataRamana.Gali11-Jul-06 2:35
VenkataRamana.Gali11-Jul-06 2:35 
AnswerRe: How to Pass multiple arugumnets Pin
dwatkins@dirq.net11-Jul-06 4:31
dwatkins@dirq.net11-Jul-06 4:31 
QuestionTwo Way Sorting with Up/Down Arrow Pin
wEb GuRu...11-Jul-06 1:35
wEb GuRu...11-Jul-06 1:35 
AnswerRe: Two Way Sorting with Up/Down Arrow Pin
Saifi Hasan11-Jul-06 2:28
Saifi Hasan11-Jul-06 2:28 
GeneralRe: Two Way Sorting with Up/Down Arrow Pin
wEb GuRu...11-Jul-06 22:21
wEb GuRu...11-Jul-06 22:21 
QuestionConvert aspx pages to html Pin
Vipin Venugopal11-Jul-06 0:34
Vipin Venugopal11-Jul-06 0:34 
AnswerRe: Convert aspx pages to html Pin
Paddy Boyd11-Jul-06 0:57
Paddy Boyd11-Jul-06 0:57 
GeneralRe: Convert aspx pages to html Pin
dwatkins@dirq.net11-Jul-06 3:57
dwatkins@dirq.net11-Jul-06 3:57 
QuestionHow to provide method level security for Webservice methods Pin
IamMohan11-Jul-06 0:30
IamMohan11-Jul-06 0:30 
QuestionOutproc session mgt in ASP . Net Pin
ankushmn11-Jul-06 0:08
ankushmn11-Jul-06 0:08 
AnswerRe: Outproc session mgt in ASP . Net Pin
Saifi Hasan11-Jul-06 2:38
Saifi Hasan11-Jul-06 2:38 
GeneralRe: Outproc session mgt in ASP . Net Pin
ankushmn11-Jul-06 3:28
ankushmn11-Jul-06 3:28 
QuestionDropDownList databinding error Pin
For_IT10-Jul-06 23:45
For_IT10-Jul-06 23:45 
AnswerRe: DropDownList databinding error Pin
Not Active11-Jul-06 2:30
mentorNot Active11-Jul-06 2:30 
GeneralRe: DropDownList databinding error Pin
For_IT11-Jul-06 2:35
For_IT11-Jul-06 2:35 
GeneralRe: DropDownList databinding error Pin
sudharsong11-Jul-06 19:57
sudharsong11-Jul-06 19:57 
QuestionStatic Variable Vs. Application Object stored variable Pin
Abhinav Nigam10-Jul-06 23:42
Abhinav Nigam10-Jul-06 23:42 
AnswerRe: Static Variable Vs. Application Object stored variable Pin
IamMohan11-Jul-06 0:49
IamMohan11-Jul-06 0:49 
QuestionCreate run time asp.net page Pin
Parwej Ahamad10-Jul-06 23:36
professionalParwej Ahamad10-Jul-06 23:36 
AnswerRe: Create run time asp.net page Pin
Guffa11-Jul-06 0:03
Guffa11-Jul-06 0:03 
AnswerRe: Create run time asp.net page Pin
Saifi Hasan11-Jul-06 2:35
Saifi Hasan11-Jul-06 2:35 
Questionhow to restrict row and column size in Excelsheet Pin
Bridzet10-Jul-06 23:09
Bridzet10-Jul-06 23:09 
QuestionEvents not responding after re-creation of dynamically created webcontrols [modified] Pin
oxiroxt10-Jul-06 22:37
oxiroxt10-Jul-06 22:37 
Hi everyone,

I have a situation where I must add ImageButtons dynamically on a page. This I managed to do, but I need them to respond to the Click event and they won't.

Here's a snippet which represents what I'm doing:
public partial class _Default : System.Web.UI.Page
{
    ArrayList imagenes = new ArrayList();

    protected void Page_Load(object sender, EventArgs e)
    {

        if (!Page.IsPostBack)
        {
            ImageButton ib3 = new ImageButton();
            ib3.ID = "ib3";
            ib3.ImageUrl = "Puesta de sol.jpg";
            ib3.Click += new ImageClickEventHandler(ImageButton_Click);
            ib3.Width = new Unit(100, UnitType.Pixel);
            ib3.Height = new Unit(100, UnitType.Pixel);
            form1.Controls.Add(ib3);
            imagenes.Add(ib3);

            Session["Imagenes"] = imagenes;
        }
        else
        {
            imagenes = (ArrayList)Session["Imagenes"];
            foreach (ImageButton ib in imagenes)
                form1.Controls.Add(ib);
        }
    }

    protected void ImageButton_Click(object sender, ImageClickEventArgs e)
    {
        Page.ClientScript.RegisterStartupScript(GetType(), null, "alert('HEY');", true);
    }
}


After clicking on the ImageButton, the page reloads, enters the Else clause, the ImageButton is restored, but it won't enter the Click handler.
Also, I tried setting the handler manually inside the Else clause after the control has been added to the form but it won't enter the handler either.

My guess is this is happening because asp.net is actually assigning the handler, but the call to the handler is simply 'lost' during the restoration of the controls since it appears asp.net expects to fire events for 'static' controls only.

I've checked that when a Click event is fired for a 'static' ImageButton, the execution path goes through the Page_Load first and ends into the handler. That's why i re-create the control in the Else clause in Page_Load.

It's not as important for me to get every delegate for each control restored(which i guess it actually is) and working, as it is getting all of them getting into one handler as expected, since I'll possibly assing all of them the same handler.

Thanks a lot in advance for any help you could provide,

Oxi

-- modified at 4:52 Tuesday 11th July, 2006
AnswerRe: Events not responding after re-creation of dynamically created webcontrols Pin
oxiroxt10-Jul-06 23:12
oxiroxt10-Jul-06 23:12 
QuestionPrint Headers of Datagrid on Multiple Pages Pin
varun_khanna1710-Jul-06 22:15
varun_khanna1710-Jul-06 22:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.