Click here to Skip to main content
15,899,662 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
This is first times i met an error like this .I have also tried to find, but it is not successfully.
This is the whole my code
Here is my code

default.aspx.cs

C#
protected void Page_Load(object sender, EventArgs e)
{
if (!base.IsPostBack)
{
switch (((base.Request.QueryString["Page"] != null) ? base.Request.QueryString["Page"].ToUpper() : "HOME"))
{
case "CONTACT":
phdDefault.Controls.Clear();
Control myUserControl = (Control)Page.LoadControl("Modules/WebUserControl.ascx");
phdDefault.Controls.Add(myUserControl);
break;
}
}
}

WebUserControl.ascx.cs
HTML
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />
<asp:Label ID="Label1" runat="server"></asp:Label>
Code behind
C#
protected void Button1_Click(object sender, EventArgs e)
{
// OnBubbleClick(e);
TextBox1.Text = "";
Label1.Text = "What is this an error ?";
}

Do not capture the value. on Button click
Please help me
Thanks
Phuc Hoang
Posted
Updated 17-Jun-11 16:25pm
v4
Comments
Sergey Alexandrovich Kryukov 17-Jun-11 22:22pm    
I added pre tag for code. Could you also format it? It's not well readable right now.
--SA
Sergey Alexandrovich Kryukov 17-Jun-11 22:24pm    
I also added ASP.NET tag is it correct? Always tag essential things like platform, language, UI library, technology.
--SA
Arindam Tewary 18-Jun-11 17:32pm    
What is "phdDefault" ?What is this control?

1 solution

Hello!

After testing something similar to your code, I saw that, beacause we load the control in an (!IsPostBack) clause, the control is no longer added after postback.

Adding the control outside the (!IsPostBack) clause should take care of the problem.

Hope this helps! Happy coding!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900