如何获取ListView中DataPager的子控件的ClientID
我在ListView中的DataPager中
<asp:DataPager ID="DataPager1" runat="server" PageSize="5" QueryStringField="pageNum">
<Fields>
<asp:NextPreviousPagerField ButtonType="Button" ShowFirstPageButton="True"
ShowLastPageButton="False" ShowPreviousPageButton="true" ShowNextPageButton="false" />
<asp:NumericPagerField ButtonType="Link" />
<asp:NextPreviousPagerField ButtonType="Button" ShowLastPageButton="true" ShowNextPageButton="true" ShowFirstPageButton="false" ShowPreviousPageButton="false"/>
<asp:TemplatePagerField><PagerTemplate><Label for="pageGo">跳转到:<Label><input type="text" runat="server" id="txtPageGo"/><asp:Button
ID="btnGo" runat="server" Text="Go" /></PagerTemplate></asp:TemplatePagerField></Fields></asp:DataPager>
后来我在后台的Page_Load中写入
protected void Page_Load(object sender, EventArgs e)
{
//TODO:为什么不能获取到ClientID的值
//string str = ((Button)(lvNews.Page.FindControl("btnGo"))).ClientID;
//Response.Write(str);
}
为什么会出现btnGo 引用对象为空
如何去获取它
--------------------编程问答-------------------- LZ你不会是把DataPager放在ListView的ItemTemplate里吧 结果会很悲剧啊 以前没用过所以自己用了试结果这样:
第一页 上一页 1 2 下一页 最后一页 跳转到:Go
第一页 上一页 1 2 下一页 最后一页 跳转到:Go
第一页 上一页 1 2 下一页 最后一页 跳转到:Go
第一页 上一页 1 2 下一页 最后一页 跳转到:Go
第一页 上一页 1 2 下一页 最后一页 跳转到:Go
第一页 上一页 1 2 下一页 最后一页 跳转到:Go --------------------编程问答-------------------- 没有放在ListView的ItemTemplate里,不过在前台用javascript的getElementById可以取到,但在服务端不能用FindControl找到,求解 --------------------编程问答-------------------- --------------------编程问答-------------------- 我那也有这问题,感觉功能不完善,也有可能咱没找到正确方法。。。
补充:.NET技术 , ASP.NET