Solved

Geting the width of a detailsview at runtime

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

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…
Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
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…

744 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now