I am trying to duplicate the above in a web control. Both the image and textbox need to be centered vertically. The image is easy - it will always be the same size. The text however is not as it's size depends on the length of the text.
The code below is a page which displays the above.
The question is how to get the Javscript to operate on the label in the control, if there is more than one of these on the page - there will be more than one label?
PAULSC
Member
41 Points
22 Posts
embedding javascript that acts on child controls of a webcontrol
Jan 30, 2012 08:20 PM|LINK
I am trying to duplicate the above in a web control. Both the image and textbox need to be centered vertically. The image is easy - it will always be the same size. The text however is not as it's size depends on the length of the text.
The code below is a page which displays the above.
<body> <script type="text/javascript"> $(document).ready(function () { var topPos = ($('#container').height() / 2) - ($('#buttonLabel').height() / 2) $('#buttonLabel').css("top", topPos); }); </script> <form id="form1" runat="server"> <div id="container"> <img alt="Find Location" src="Images/MapIcon.png" style="height:32px; width:32px; position:absolute; top:48px; left:10px;" /> <label style="position:absolute; left:52px; " id="buttonLabel">Find Meeting Location</label> </div> </form> </body>The question is how to get the Javscript to operate on the label in the control, if there is more than one of these on the page - there will be more than one label?
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: embedding javascript that acts on child controls of a webcontrol
Feb 01, 2012 12:02 AM|LINK
Label——If you run your aspx app proj and right click to see the source codes,it's:
<span>……</span>
So you can just do this:
$("span").each(function(){$(this).text("Your real contents here");})