Solved

Geting the width of a detailsview at runtime

Posted on 2011-09-07
3
243 Views
Last Modified: 2012-05-12
Hello Experts,

I'm getting the impression this isn't as easy as I'd like it to be.  Still, I need to be able to retrieve the width of my detailsview object at runtime.  It expands to the length of the content, so it can be any width.

Essentially I need to be able to mirror it's look with a table, and that all works except I don't know what to set the table width to.

I'd prefer a server-side solution, but have a sinking feeling it may require require javascript.

Thanks!
Moe
0
Comment
Question by:mauricerichard
3 Comments
 
LVL 51

Assisted Solution

by:HainKurt
HainKurt earned 200 total points
ID: 36497800
here:

<table id=tbl><tr><td>Hain Kurt</td></tr></table>
<script>
alert(tbl.clientWidth);
</script>

you may need to use

tbl.clientWidth
-->
<%tbl.ClientID%>.clientWidth

or

document.getElementById("<%tbl.ClientID%>").clientWidth
0
 
LVL 12

Accepted Solution

by:
Ramkisan Jagtap earned 300 total points
ID: 36528482
Hi,
You can place a hidden field on the page. Make it runat server. Set the hidden field value to with details view width using javascript. Then access the hidden field value at Server side.

Regards,
Ram
0
 
LVL 1

Author Closing Comment

by:mauricerichard
ID: 36551590
Great advice, thanks very much!
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question