又发现Atlas中UpdatePanel的一个控件兼容问题,不知道有没有人碰到过。思归,孟子等高手们都来看看吧。详情见内!
我的页面十分简单,在一个页面Test.aspx上放一个UpdatePanel1,里面放了一个PlaceHolder1控件和一个Button1按钮,点击Button时动态加载一个UserControl(WebUserControl.ascx),UserControl里有一个LinkButton1和一个TextBox1,点击LinkButton1使得TextBox1的Text加上等于“ABC”。
Test.aspx代码:
public partial class Test : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (ViewState["ControlID"] != null)
{
AddControl();
}
}
protected void Button1_Click(object sender, EventArgs e)
{
ViewState["ControlID"] = "WebUserControl";
AddControl();
}
private void AddControl()
{
UserControl uc = (UserControl)LoadControl("~/WebUserControl.ascx");
uc.ID = "WebUserControl";
this.PlaceHolder1.Controls.Clear();
this.PlaceHolder1.Controls.Add(uc);
}
}
WebUserControl.ascx代码:
public partial class WebUserControl : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void LinkButton1_Click(object sender, EventArgs e)
{
this.TextBox1.Text += "ABC";
}
}
前置页代码我就不贴了,很简单,控件托上去就有了。
我的UpdatePanel的设置都没问题,Atlas的版本也最新。我用Button代替LinkButton就没问题,但用LinkButton就会报Javascript的错误。
不知哪位高手可以解决?小弟在这里多谢了!