Click here to Skip to main content
15,909,835 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: insertion of image in sql sever 2000 Pin
Oakman10-Jan-08 16:48
Oakman10-Jan-08 16:48 
GeneralRe: insertion of image in sql sever 2000 Pin
Paul Conrad10-Jan-08 16:53
professionalPaul Conrad10-Jan-08 16:53 
GeneralRe: insertion of image in sql sever 2000 Pin
73Zeppelin10-Jan-08 21:50
73Zeppelin10-Jan-08 21:50 
GeneralRe: insertion of image in sql sever 2000 Pin
#realJSOP11-Jan-08 11:11
professional#realJSOP11-Jan-08 11:11 
Generalfit header to screen size Pin
eyeseetee8-Jan-08 21:59
eyeseetee8-Jan-08 21:59 
GeneralRe: fit header to screen size Pin
Declan Bright8-Jan-08 22:32
Declan Bright8-Jan-08 22:32 
GeneralRe: fit header to screen size Pin
eyeseetee8-Jan-08 22:44
eyeseetee8-Jan-08 22:44 
QuestionNested web user control created dinamically Pin
Federico Orlandini8-Jan-08 21:54
Federico Orlandini8-Jan-08 21:54 
Hi all,

I have the following scenario: I have a web user control (ParentControl.ascx) which has a menu with 2 linkbuttons and a placeholder.
If I click on the first linkbutton, the control load dinamically a ChildControl1.ascx in the placeholder. The ChildControl1 is composed by 1 label and 2 buttons: if I press the first, the text of the label's text change to "Alfa". If I press the second, the label's text change to "Bravo".
If I click on the second linkbutton, the control load dinamically a ChildControl2.ascx in the placeholder. The ChildControl2 is composed by 1 label and 3 buttons: if I press the first, the text of the label's text change to "Qui". If I press the second, the label's text change to "Quo". If I press the 3th, the label's text change to "Qua".

If I run the web application I can see the linkbuttons. Clicking I can got the child control but the strange thing is the following. If I press on the a linkbutton (the first for example) and I try to click on a button of the child control nothing happen, the label text didn't change (even if there is a postback). If I press the same button (of che childcontrol) another time, the label's text change.
Confused | :confused:

This strange thing happen only when I switch from a child control to the other.

This is the ParentControl's code:

public partial class ParentControl : System.Web.UI.UserControl<br />
{<br />
    protected void Page_Load(object sender, EventArgs e)<br />
    {<br />
        if (ViewState["SelectedControl"] != null)<br />
        {<br />
            switch (ViewState["SelectedControl"].ToString())<br />
            {<br />
                case "Control1":<br />
                    PlaceHolder1.Controls.Add(LoadControl("ChildControl.ascx"));<br />
                    break;<br />
                case "Control2":<br />
                    PlaceHolder1.Controls.Add(LoadControl("ChildControl2.ascx"));<br />
                    break;<br />
            }<br />
        }<br />
    }<br />
    protected void LinkButton1_Click(object sender, EventArgs e)<br />
    {<br />
        Control ctrl = LoadControl("ChildControl.ascx");<br />
        PlaceHolder1.Controls.Clear();<br />
        PlaceHolder1.Controls.Add(ctrl);<br />
        ViewState["SelectedControl"] = "Control1";<br />
    }<br />
    protected void LinkButton2_Click(object sender, EventArgs e)<br />
    {<br />
        Control ctrl = LoadControl("ChildControl2.ascx");<br />
        PlaceHolder1.Controls.Clear();<br />
        PlaceHolder1.Controls.Add(ctrl);<br />
        ViewState["SelectedControl"] = "Control2";<br />
    }<br />
}


As you can see, I recreate all the dynamic control on the Page_Load event and I use the ViewState to store which type of child control to create.
Can you help me to understand osmething more about this strange behaviour?

Thanks
Regards
Federico

P.S. I didn't post all the code but tell me if it can help you to solve the problem.
GeneralRe: Nested web user control created dinamically Pin
Paddy Boyd8-Jan-08 23:15
Paddy Boyd8-Jan-08 23:15 
GeneralRe: Nested web user control created dinamically Pin
Federico Orlandini9-Jan-08 0:25
Federico Orlandini9-Jan-08 0:25 
QuestionRetrieving Outlook Contacts in ASP.NET Pin
T G Shiva8-Jan-08 21:46
T G Shiva8-Jan-08 21:46 
GeneralRe: Retrieving Outlook Contacts in ASP.NET Pin
Declan Bright8-Jan-08 23:04
Declan Bright8-Jan-08 23:04 
Questionhow to connect SQL Server database? [modified] Pin
Golden Jing8-Jan-08 21:21
Golden Jing8-Jan-08 21:21 
GeneralRe: how to connect SQL Server database? Pin
N a v a n e e t h8-Jan-08 21:42
N a v a n e e t h8-Jan-08 21:42 
GeneralRe: how to connect SQL Server database? Pin
Golden Jing8-Jan-08 22:09
Golden Jing8-Jan-08 22:09 
GeneralRe: how to connect SQL Server database? Pin
N a v a n e e t h8-Jan-08 22:17
N a v a n e e t h8-Jan-08 22:17 
GeneralRe: how to connect SQL Server database? Pin
janet20088-Jan-08 22:39
janet20088-Jan-08 22:39 
GeneralRe: how to connect SQL Server database? Pin
Golden Jing8-Jan-08 22:44
Golden Jing8-Jan-08 22:44 
GeneralRe: how to connect SQL Server database? Pin
Golden Jing8-Jan-08 22:39
Golden Jing8-Jan-08 22:39 
GeneralRe: how to connect SQL Server database? Pin
janet20088-Jan-08 22:48
janet20088-Jan-08 22:48 
GeneralRe: how to connect SQL Server database? Pin
N a v a n e e t h9-Jan-08 19:01
N a v a n e e t h9-Jan-08 19:01 
Questionshow the image in table control Pin
Basheer8-Jan-08 20:56
Basheer8-Jan-08 20:56 
GeneralRe: show the image in table control Pin
pmarfleet8-Jan-08 22:09
pmarfleet8-Jan-08 22:09 
Generalserver and client in asp.net Pin
chanzeb8-Jan-08 20:53
chanzeb8-Jan-08 20:53 
GeneralRe: server and client in asp.net Pin
pmarfleet8-Jan-08 22:08
pmarfleet8-Jan-08 22:08 

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.