javascript - LinkButton.Text coming undefined in js -
i want configure hyperlink close/open related div in asp.net. basically, when user clicks sign x, panel should closed , sign + should appeared. when + clicked, panel should showed again. not manage , believe main problem "document.getelementbyid('<%= lb_closepanel.clientid %>').value" coming undefined. here code until now. appreciate helps!
<!doctype html> .... <div class="appheader"> <h1 class="appheadercontent">search client</h1> <div id="checkbox"></div> <div id="closepanel"><h2 id="lblclosepanel">close panel</h2> <div id="xbutton"> <asp:linkbutton onclientclick="closeopenpanel('search')" runat="server" text="x" style="text-decoration:none; color:white" id="lb_closepanel"></asp:linkbutton> </div> </div> </div> <div class="app" id="search"> ... <div> ... </html> <script type="text/javascript"> function closeopenpanel(obj) { alert(document.getelementbyid('<%= lb_closepanel.clientid %>').value); //here comes undefined!!!! if (document.getelementbyid('<%= lb_closepanel.clientid %>').value == 'x') { document.getelementbyid(obj).visible = false; lb_closepanel.text = '+'; } else { document.getelementbyid(obj).visible = true; lb_closepanel.text = 'x'; } } </script>
your code ok, instead of property value
use innerhtml
alert(document.getelementbyid('<%= lb_closepanel.clientid %>').innerhtml);
Comments
Post a Comment