Click here to Skip to main content
15,910,603 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: Asp.net system. diagnostics.process access denied Pin
Eddy Vluggen1-Sep-12 3:57
professionalEddy Vluggen1-Sep-12 3:57 
Questionasp c# Pin
ajis23261-Sep-12 1:25
ajis23261-Sep-12 1:25 
AnswerRe: asp c# Pin
Richard MacCutchan1-Sep-12 2:35
mveRichard MacCutchan1-Sep-12 2:35 
AnswerRe: asp c# Pin
Sandeep Mewara1-Sep-12 10:34
mveSandeep Mewara1-Sep-12 10:34 
QuestionSlideShowExtender Pin
pknarun31-Aug-12 21:35
pknarun31-Aug-12 21:35 
Questionhow to display the gridview content Pin
kumaranvnr31-Aug-12 19:03
kumaranvnr31-Aug-12 19:03 
AnswerRe: how to display the gridview content Pin
Sandeep Mewara1-Sep-12 10:38
mveSandeep Mewara1-Sep-12 10:38 
Questionquick answer for me Pin
mamnafih31-Aug-12 0:57
mamnafih31-Aug-12 0:57 
AnswerRe: quick answer for me Pin
Keith Barrow31-Aug-12 1:11
professionalKeith Barrow31-Aug-12 1:11 
AnswerCross post Pin
Wes Aday31-Aug-12 1:40
professionalWes Aday31-Aug-12 1:40 
GeneralRe: Cross post Pin
Keith Barrow31-Aug-12 1:47
professionalKeith Barrow31-Aug-12 1:47 
GeneralRe: Cross post Pin
Wes Aday31-Aug-12 3:38
professionalWes Aday31-Aug-12 3:38 
GeneralRe: Cross post Pin
Shameel31-Aug-12 5:30
professionalShameel31-Aug-12 5:30 
QuestionQuestion about carrying information from a HTML page to a ASP Pin
Diego Carrion30-Aug-12 18:10
Diego Carrion30-Aug-12 18:10 
GeneralRe: Question about carrying information from a HTML page to a ASP Pin
Deflinek31-Aug-12 4:00
Deflinek31-Aug-12 4:00 
GeneralRe: Question about carrying information from a HTML page to a ASP Pin
Diego Carrion31-Aug-12 4:34
Diego Carrion31-Aug-12 4:34 
GeneralRe: Question about carrying information from a HTML page to a ASP Pin
Deflinek31-Aug-12 5:03
Deflinek31-Aug-12 5:03 
GeneralRe: Question about carrying information from a HTML page to a ASP Pin
Diego Carrion31-Aug-12 5:07
Diego Carrion31-Aug-12 5:07 
GeneralRe: Question about carrying information from a HTML page to a ASP Pin
Deflinek31-Aug-12 22:15
Deflinek31-Aug-12 22:15 
GeneralRe: Question about carrying information from a HTML page to a ASP Pin
Diego Carrion2-Sep-12 5:26
Diego Carrion2-Sep-12 5:26 
QuestionASP.NET Pin
soumyashree sahoo30-Aug-12 17:28
soumyashree sahoo30-Aug-12 17:28 
AnswerRe: ASP.NET Pin
Sandeep Mewara30-Aug-12 18:57
mveSandeep Mewara30-Aug-12 18:57 
Questioncant insert image in table Pin
Michael Portanoba30-Aug-12 16:56
Michael Portanoba30-Aug-12 16:56 
AnswerRe: cant insert image in table Pin
Sandeep Mewara30-Aug-12 18:55
mveSandeep Mewara30-Aug-12 18:55 
QuestionButton event does not execute Pin
netJP12L30-Aug-12 0:58
netJP12L30-Aug-12 0:58 
Hi Guys,
I am loading buttons on a page load event dynamically. The buttons are added to a placeholder control on a aspx page. The problem I am having is that the dynamically created button event below (topic_Click) doesn't get fired.
Bascially, I am trying to add topics to aobjective.
Could you please help me. I would highly appreciate it.
C#
protected void Page_Load(object sender, EventArgs e)
{
       
        if (Session["s"] == null)
        {
            AddObjective();
            AddTopic();
        }
        else if (Session["s"] != null)
        {
            List<Panel> list = new List<Panel>();
            list = Session["s"] as List<Panel>;
            foreach (var item in list)
            {
                AddtoPlaceHolder(item);
            }
        }
    }

private void AddObjective()
{
        Panel panel = new Panel();
        Button objective = new Button();
        objective.Text = "Add objective";
        objective.Click += new EventHandler(objective_Click);
        panel.Controls.Add(objective);
        placeholder.Controls.Add(panel);

        AddtoPlaceHolder(panel);       
    }

void AddtoPlaceHolder(Panel panel)
{
        if (Session["s"] == null)
        {
            List<Panel> list = new List<Panel>();
            list.Add(panel);
            Session.Add("s", list);
        }
        else if(Session["s"] !=null)
        {
            List<Panel> list = Session["s"] as List<Panel>;
            list.Add(panel);
            Session.Add("s", list);
        }
    }

void objective_Click(object sender, EventArgs e)
{
        if (Session["s"] != null)
        {
            AddObjective();
        } 
}

void topic_Click(object sender, EventArgs e)
{
       throw new NotImplementedException();    =======> Problem doesn't execute         
}

private void AddTopic()
{
       Panel paneltopic = new Panel();
        paneltopic.ID = Guid.NewGuid().ToString(); 
        Button topic = new Button();
        topic.ID = Guid.NewGuid().ToString();
        topic.Text = "Insert topic";
        topic.Click += new EventHandler(topic_Click);
        paneltopic.Controls.Add(topic);
        placeholder.Controls.Add(paneltopic);

        AddtoPlaceHolder(paneltopic);
}

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.