c# - Control does not show up in CodeBehind? -
i have masterpage:
<%@ master language="c#" autoeventwireup="true" codebehind="kezberprojectmanager.master.cs" inherits="kezberprojectmanager.kezberprojectmanager" %> <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <!-- le styles --> <link href="assets/css/bootstrap.css" rel="stylesheet"/> <link href="assets/css/bootstrap-responsive.css" rel="stylesheet"/> <link href="assets/css/kezblu.styles.css" rel="stylesheet"/> <style type="text/css"> </style> <!-- le html5 shim, ie6-8 back upwards of html5 elements --> <!--[if lt ie 9]> <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> <script type="text/javascript" src="http://code.jquery.com/jquery-1.9.0.min.js"></script> <script type="text/javascript" src="assets/js/kezcommon.js"></script> <script type="text/javascript"> $(document).ready ( function () { createautoclosingalert('.success_alert', 6000); } ); function createautoclosingalert(selector, delay) { var alert = $(selector).alert(); window.settimeout(function () { $(alert).slideup() }, delay); } </script> <asp:contentplaceholder id="head" runat="server"> </asp:contentplaceholder> </head> <body> <form id="form1" runat="server"> <asp:repeater runat="server" id="menurepeater"> <headertemplate> <div class="navbar navbar-inverse navbar-fixed-top"> <div class="navbar-inner"> <div class="container"> <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse"> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </a> <a class="brand" href="#">kezblu</a> <div class="nav-collapse collapse"> <ul class="nav"> </headertemplate> <itemtemplate> <%# eval("content") %> </itemtemplate> <footertemplate> </ul> </div><!--/.nav-collapse --> </div> </div> </div> </footertemplate> </asp:repeater> <div id="wrap"> <div id="content"> <div id="alerts"> <div class="bs-docs-example"> <div id="auth"> <asp:hyperlink id="hyperlink1" runat="server">hyperlink</asp:hyperlink> </br> <asp:hyperlink id="hyperlink2" runat="server">hyperlink</asp:hyperlink> </div> <div runat="server" id="success_alert" class="success_alert alert alert-success fade in"> <button type="button" class="close" data-dismiss="alert">×</button> <div runat="server" id="success_alert_text"> </div> </div> </div> <div class="bs-docs-example"> <div runat="server" id="error_alert" class="error_alert alert alert-error fade in"> <button type="button" class="close" data-dismiss="alert">×</button> <div runat="server" id="error_alert_text"> </div> </div> </div> </div> <asp:contentplaceholder id="contentplaceholder1" runat="server"> </asp:contentplaceholder> </div> </div> </form> <!-- le javascript ================================================== --> <!-- placed @ end of document pages load faster --> <script type="text/javascript" src="assets/js/bootstrap.min.js"></script> </body> </html>
in there have:
<div id="auth"> <asp:hyperlink id="hyperlink1" runat="server">hyperlink</asp:hyperlink> </br> <asp:hyperlink id="hyperlink2" runat="server">hyperlink</asp:hyperlink> </div>
like this, links show fine in code behind.
now, if move them repeater's footer:
...
<div class="nav-collapse collapse"> <ul class="nav"> </headertemplate> <itemtemplate> <%# eval("content") %> </itemtemplate> <footertemplate> </ul> <div id="auth"> <asp:hyperlink id="hyperlink1" runat="server">hyperlink</asp:hyperlink> </br> <asp:hyperlink id="hyperlink2" runat="server">hyperlink</asp:hyperlink> </div> </div><!--/.nav-collapse --> </div> </div> </div> </footertemplate> </asp:repeater>
then no longer can used in code behind.
i really not understand this.
why not working?
the repeateritem
has different namingcontainer
. can access controls on top of page straight since these controls created in partial codebehind class automatically. have utilize findcontrol
reference of command in repeateritem
.
in case utilize repeater
's itemdatabound
event:
protected void repater1_itemdatabound(object sender, repeateritemeventargs e) { // event raised header, footer, separators, , items. if (e.item.itemtype == listitemtype.footer) { hyperlink hl = (hyperlink)e.item.findcontrol("hyperlink1"); } }
c# asp.net
No comments:
Post a Comment