关于用户控件的引用问题 我在index.aspx中动态添加了用户控件,用户控件中绑定了一个datalist和一些按钮 ,结果我在运行界面的时候,发现点击用户控件中的按钮,但并没有触发click事件,而且断点也没进去,不知道是哪里出了问题 ,麻烦大家指教下。。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 protected void Page_Load(object sender, EventArgs e) { SmallClassID = Convert.ToInt32(hf.Value); PageIndex = 1; PageSize = 5; OrderBy = "createTime desc"; BindDlSource(); } protected void BindDlSource() { RecordCount = NewsManager.GetNewsByPage(SmallClassID, PageIndex, PageSize, OrderBy).Count; lblCurrentPage.Text = "第" + PageIndex.ToString() + "页 共" + PageCount + "页"; dlSource.DataSource = NewsManager.GetNewsByPage(SmallClassID, PageIndex, PageSize, OrderBy); dlSource.DataBind(); } #region 分页 //首页 protected void btnFirst_Click(object sender, EventArgs e) { PageIndex = 1; BindDlSource(); } //上一页 protected void btnPre_Click(object sender, EventArgs e) { if (PageIndex > 1) PageIndex--; BindDlSource(); } //下一页 protected void btnNext_Click(object sender, EventArgs e) { if (PageIndex < PageCount) PageIndex++; BindDlSource(); } //末页 protected void btnLast_Click(object sender, EventArgs e) { PageIndex = PageCount; BindDlSource(); } //跳转 protected void btnGo_Click(object sender, EventArgs e) { try { int goPage = Convert.ToInt32(txtPage.Text.Trim()); if (goPage >= 1 && goPage <= PageCount) { PageIndex = goPage; BindDlSource(); } } catch { txtPage.Text = string.Empty; } }就是click的事件都没执行 page_onLoad加上这个if(!isPostback){}//再贴在页面上引用的代码! 加上if(!isPostback){ } 的话 页面根本就不进去的把用户控件直接拖到界面上是可以用的 就动态加载的话 click的事件触发不了有没有谁知道呀~~~~~~~~~~~help啊~~~~~~~~ protected void rptTitle_ItemCommand(object source, RepeaterCommandEventArgs e) { int smallClassId = Convert.ToInt32(e.CommandArgument); if (e.CommandName == "getNews") { SmallClass smallClass = SmallClassManager.GetSmallClassById(smallClassId); switch (smallClass.TypeName) { case "图片类": ph.Dispose(); //ph.Controls.Clear(); Contorls_DLControl dl = Page.LoadControl("~/Contorls/dlControl.ascx") as Contorls_DLControl; HiddenField pic = (HiddenField)dl.FindControl("hf"); pic.Value = smallClass.SmallClassId.ToString(); ph.Controls.Add(dl); break; case "信息类": ph.Dispose(); //ph.Controls.Clear(); Contorls_GVControl gv = Page.LoadControl("~/Contorls/gvControl.ascx") as Contorls_GVControl; HiddenField info = (HiddenField)gv.FindControl("hf"); info.Value = smallClass.SmallClassId.ToString(); ph.Controls.Add(gv); break; case "简介类": ph.Dispose(); //ph.Controls.Clear(); Contorls_DVControl dv = Page.LoadControl("~/Contorls/dvControl.ascx") as Contorls_DVControl; HiddenField intr = (HiddenField)dv.FindControl("hf"); intr.Value = smallClass.SmallClassId.ToString(); ph.Controls.Add(dv); break; } } 同个类里面2个方法之间如何调用数据源 ASP.NET看来真害了不少人 webservice 我这样写有问题吗 一个超级无敌简单的SQL问题 DataGrid.ItemCommand事件的激活问题!请给予指教! repeater 分页,分页是数字,不是上一页,下一页的,那位能提示下呀,谢了 如何使一个label的内容在浏览器中居中显示? 有为asp.net系统做过支付接口的朋友吗? 一个入门级的简单问题 三层或多层树形结构的问题!!!!在线等待!!! GridView 中itemtemplate 换行 如何将图片缩放形式显示
protected void Page_Load(object sender, EventArgs e)
{
SmallClassID = Convert.ToInt32(hf.Value);
PageIndex = 1;
PageSize = 5;
OrderBy = "createTime desc";
BindDlSource();
} protected void BindDlSource()
{
RecordCount = NewsManager.GetNewsByPage(SmallClassID, PageIndex, PageSize, OrderBy).Count;
lblCurrentPage.Text = "第" + PageIndex.ToString() + "页 共" + PageCount + "页";
dlSource.DataSource = NewsManager.GetNewsByPage(SmallClassID, PageIndex, PageSize, OrderBy);
dlSource.DataBind();
}
#region 分页
//首页
protected void btnFirst_Click(object sender, EventArgs e)
{
PageIndex = 1;
BindDlSource();
} //上一页
protected void btnPre_Click(object sender, EventArgs e)
{
if (PageIndex > 1)
PageIndex--;
BindDlSource();
} //下一页
protected void btnNext_Click(object sender, EventArgs e)
{
if (PageIndex < PageCount)
PageIndex++;
BindDlSource();
} //末页
protected void btnLast_Click(object sender, EventArgs e)
{
PageIndex = PageCount;
BindDlSource();
} //跳转
protected void btnGo_Click(object sender, EventArgs e)
{
try
{
int goPage = Convert.ToInt32(txtPage.Text.Trim());
if (goPage >= 1 && goPage <= PageCount)
{
PageIndex = goPage;
BindDlSource();
}
}
catch
{
txtPage.Text = string.Empty;
}
}就是click的事件都没执行
}//再贴在页面上引用的代码!
}
的话 页面根本就不进去的
把用户控件直接拖到界面上是可以用的
就动态加载的话 click的事件触发不了
有没有谁知道呀~~~~~~~~~~~help啊~~~~~~~~
{
int smallClassId = Convert.ToInt32(e.CommandArgument);
if (e.CommandName == "getNews")
{
SmallClass smallClass = SmallClassManager.GetSmallClassById(smallClassId);
switch (smallClass.TypeName)
{
case "图片类":
ph.Dispose();
//ph.Controls.Clear();
Contorls_DLControl dl = Page.LoadControl("~/Contorls/dlControl.ascx") as Contorls_DLControl;
HiddenField pic = (HiddenField)dl.FindControl("hf");
pic.Value = smallClass.SmallClassId.ToString();
ph.Controls.Add(dl);
break;
case "信息类":
ph.Dispose();
//ph.Controls.Clear();
Contorls_GVControl gv = Page.LoadControl("~/Contorls/gvControl.ascx") as Contorls_GVControl;
HiddenField info = (HiddenField)gv.FindControl("hf");
info.Value = smallClass.SmallClassId.ToString();
ph.Controls.Add(gv);
break;
case "简介类":
ph.Dispose();
//ph.Controls.Clear();
Contorls_DVControl dv = Page.LoadControl("~/Contorls/dvControl.ascx") as Contorls_DVControl;
HiddenField intr = (HiddenField)dv.FindControl("hf");
intr.Value = smallClass.SmallClassId.ToString();
ph.Controls.Add(dv);
break;
}
}