Page_Load怎么会执行两次?超怪的问题,会者不难 你使用VS.net开发asp.net就不会出现这个问题注意AutoEventWireup="false" 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 首先改正你的Page_load,改成如下private void Page_Load(object send, EventArgs e){ //userControlSample thePagelet = (userControlSample)Page.LoadControl("default.ascx"); //thePagelet.TextBoxText = "This is a TextBox"; //thePagelet.LabelText = "This is a Label"; //htmlForm.Controls.Add(thePagelet); if (!Page.IsPostBack) { htmlForm.Controls.Add(new LiteralControl("<h3>Content</h3>")); }}然后把在html代码中的注释去掉,asp.net运行库非常灵敏,如果你加入asp.net的控件代码,加入注释也不行,asp.net运行库一样可以识别,把注释删除即可。 <a>在这个标签里面给javascript事件 Request.QueryString取值错误 VS2008下如何创建一个业务逻辑层? 关于SQLServer Desktop Engine的部署问题 看看下面的代码有没有问题,如果有,如何修改? 关于工具箱的问题 新手问题:关于用户控件 请教下使用IE自带打印功能实现证书、报表套打的设计经验与好的方法 想做软件测试方面的工作 51testing怎样--急需 这个是怎么回事啊?求大神解 如何在web页上使用有界面的atl控件?请指教! 思归大侠,又一棘手问题,在客户端打开网页时实现PC 喇叭发音,asp.net+c#!
private void Page_Load(object send, EventArgs e)
{
//userControlSample thePagelet = (userControlSample)Page.LoadControl("default.ascx");
//thePagelet.TextBoxText = "This is a TextBox";
//thePagelet.LabelText = "This is a Label";
//htmlForm.Controls.Add(thePagelet);
if (!Page.IsPostBack)
{
htmlForm.Controls.Add(new LiteralControl("<h3>Content</h3>"));
}
}
然后把在html代码中的注释去掉,asp.net运行库非常灵敏,如果你加入asp.net的控件代码,加入注释也不行,asp.net运行库一样可以识别,把注释删除即可。