Solved

Geting the width of a detailsview at runtime

Posted on 2011-09-07
3
242 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
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…

808 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