473,404 Members | 2,195 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

How to evaluate the dimensions of a <div>

Hello, I'm fairly new to asp.net programming (I come from a C++ background)
and am still finding some things very confusing. I wondered if anyone could
help me with the following issue.

I managed to add a handler function to my project which uses GDI+ to resize
a largish image down to an arbitray size. Now I'd like to be able to get the
required sizes programatically from the enclosing <divbut I'm struggling
to see how to do that.

For example, I have the following in a test.aspx page.

<div id="Frame" style="width:200px; height:200px;">

<img src="Resize.ashx?Image=Images/BigImage.jpg&Width=<% ???? %>&Height=<%
???? %>" >

</div>

This works fine if I just substitute = "200" for ???? but is there anything
I can put inside the <% %which will evaluate to the actual width and
height of any enclosing div?

Many Thanks for any help
Jeff
Oct 21 '08 #1
4 1489

Sorry to reply to my own post....

I figured that it probably isn't possible to get at the run time size of the
image from within the page itself, so I added some public variable which I
evaluate at page load. Now I have something like this :-

<div>
Image size = <%=Width %x <%=Height %>
<img id="myImage" runat="server"
src="Resize.ashx?Image=Images/BigImage.jpg&Width=<%=Width %>" style="width:
400px; height: 400px" />
<\div>

Stepping through the code I see that the values for Width and Height are
correctly evaluated in Page_Load and when I run the page the correct values
are substituted into the text "Image size= 400 x 400".

But unfortunately in my handler, context.Request["Width"] evaluates to
<%=Width%instead of 400.

So where am I going wrong?

Thanks for any help

Jeff

Oct 21 '08 #2
This is just literal values. If I remember you'll have to do soemthign such
:

src='<%="Resize.ashx?Image=...&Width"+Width.ToStri ng%>' to get the effect
you want. so that ASP.NET recogniez that you introduce an expression into
this property.

I don't guarantee this syntax as my personal preference is to avoid
expression in ASPX markup and to go in this my code behind file :

MyImage.src=MyExpression...

--
Patrice

"Jeff" <so*****@somewhere.coma écrit dans le message de groupe de
discussion : DD*********************@newsfe25.ams2...
>
Sorry to reply to my own post....

I figured that it probably isn't possible to get at the run time size of
the image from within the page itself, so I added some public variable
which I evaluate at page load. Now I have something like this :-

<div>
Image size = <%=Width %x <%=Height %>
<img id="myImage" runat="server"
src="Resize.ashx?Image=Images/BigImage.jpg&Width=<%=Width %>"
style="width: 400px; height: 400px" />
<\div>

Stepping through the code I see that the values for Width and Height are
correctly evaluated in Page_Load and when I run the page the correct
values are substituted into the text "Image size= 400 x 400".

But unfortunately in my handler, context.Request["Width"] evaluates to
<%=Width%instead of 400.

So where am I going wrong?

Thanks for any help

Jeff
Oct 21 '08 #3
<%= %can not be used to set properties of controls with runat=server,
only binding expression which require you also do a bind. just take the
runat=server off or set the properties in the codebehind.

by default a div is the size of its content, so there is no need to set
it. you can get its size at runtime with javascript.

-- bruce (sqlwork.com)

Jeff wrote:
Sorry to reply to my own post....

I figured that it probably isn't possible to get at the run time size of the
image from within the page itself, so I added some public variable which I
evaluate at page load. Now I have something like this :-

<div>
Image size = <%=Width %x <%=Height %>
<img id="myImage" runat="server"
src="Resize.ashx?Image=Images/BigImage.jpg&Width=<%=Width %>" style="width:
400px; height: 400px" />
<\div>

Stepping through the code I see that the values for Width and Height are
correctly evaluated in Page_Load and when I run the page the correct values
are substituted into the text "Image size= 400 x 400".

But unfortunately in my handler, context.Request["Width"] evaluates to
<%=Width%instead of 400.

So where am I going wrong?

Thanks for any help

Jeff
Oct 21 '08 #4

"Patrice" <http://www.chez.com/scribe/wrote in message
news:AD**********************************@microsof t.com...
This is just literal values. If I remember you'll have to do soemthign
such :

src='<%="Resize.ashx?Image=...&Width"+Width.ToStri ng%>' to get the effect
you want. so that ASP.NET recogniez that you introduce an expression into
this property.

I don't guarantee this syntax as my personal preference is to avoid
expression in ASPX markup and to go in this my code behind file :

MyImage.src=MyExpression...

--
Patrice
Thanks Patrice

I've tried every variation on this sort of thing

I can add something like

<%="Resize.ashx?Image=Images/BigImage.jpg&Width="+Width%>

outside of the object tags and it evaluates just as I want on the page.

But as soon as I put this sort of thing inside the < tags I get a message
like
Build (web): Server tags cannot contain <% ... %constructs.
Oh well - maybe I'm not meant to do this!

Jeff
Oct 21 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: Mikko Ohtamaa | last post by:
From XML specification: The representation of an empty element is either a start-tag immediately followed by an end-tag, or an empty-element tag. (This means that <foo></foo> is equal to...
1
by: Philo | last post by:
How do I select all <div> tags except those which contain a <table> tag somewhere within them? Example XML: <********************** sample input ***********************> <txtSectionBody>...
3
by: Paul Thompson | last post by:
When I put a <div ...> inside a <table> specification, functionality is not there. When I put the <table> inside the <div> everything works. Why is that?
8
by: Daniel Hansen | last post by:
I know this must seem totally basic and stupid, but I cannot find any reference that describes how to control the spacing between <p>...</p> and <div>...</div> blocks. When I implement these on a...
6
by: Marcus Otmarsen | last post by:
Ok, the situation is as follows: I defined a <DIV> like: <div id="myid" style="position: absolute; height: 10; width: 10;"><img src="images/object.gif" height=10 width=10></div> This pane is...
3
by: Josef K. | last post by:
Asp.net generates the following html when producing RadioButton lists: <td><input id="RadioButtonList_3" type="radio" name="MyRadioButtonList" value="644"...
1
by: alanchinese | last post by:
let's say i have codes like this: <form> <div> <input type="text" name="in1" size="10"> <input type="text" name="in2" size="100"> <!-- more inputs --> </div> <form> can javascript calculate...
28
by: Kent Feiler | last post by:
1. Here's some html from a W3C recommendations page. <P>aaaaaaaaa<DIV>bbbbbbbbb</DIV><DIV>cccccccc<P>dddddddd</DIV> 2.Although I didn't think it would make any difference, I tried it with the...
8
prino
by: prino | last post by:
Hi all, I've written code (in REXX) that takes files in legacy languages (PL/I, COBOL, z/OS assembler, etc) and converts them into HTML in a format similar to what's displayed in the z/OS ISPF...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.