473,669 Members | 2,420 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Storing WebControl.Widt h and WebControl.Heig ht int variables

Hi. I have an apsx page with a Panel inside. The panel has his
properties Width and Height set to 590 and 390 respectively.

I call a function to make up an table inside this panel. That table
has 2 columns. The size of the first one has 2/3 of the panel.width
and the size of the second one has 1/3 of the panel.width.

The only way I got to calculate these values was:

private void MakeCentralTabl e(Panel panel)
{
double twoThird = double.Parse(pa nel.Width.ToStr ing()) * 0.66;
double oneThird = double.Parse(pa nel.Width.ToStr ing()) * 0.33;
double half = double.Parse(pa nel.Height.ToSt ring()) * 0.5;

First I tryied to convert panel.Width and .Height this way:

double twoThird = (double) panel.Width * 0.66;

but I got an error saying that the compiler cannot cast Unit.Pixel to
double. Ok I understand I cannot cast an object to a type value. But
converto to string and follow convert to double just to store in a
double variable seems to me to much work for nothing.

Can anyone tell if there's a simpler way to do this?

Thanks
Nov 15 '05 #1
4 5608
xiko,

Instead of using actual pixels (or some other absolute unit, which
really isn't a good way to do it), why not set the Width property to a Unit
which was generated using the static Percentage method on the Unit
structure? The width of a panel is in units, and that is a combination of a
number, and a unit of measurement.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"xiko tripa" <xi*******@bol. com.br> wrote in message
news:3d******** *************** ***@posting.goo gle.com...
Hi. I have an apsx page with a Panel inside. The panel has his
properties Width and Height set to 590 and 390 respectively.

I call a function to make up an table inside this panel. That table
has 2 columns. The size of the first one has 2/3 of the panel.width
and the size of the second one has 1/3 of the panel.width.

The only way I got to calculate these values was:

private void MakeCentralTabl e(Panel panel)
{
double twoThird = double.Parse(pa nel.Width.ToStr ing()) * 0.66;
double oneThird = double.Parse(pa nel.Width.ToStr ing()) * 0.33;
double half = double.Parse(pa nel.Height.ToSt ring()) * 0.5;

First I tryied to convert panel.Width and .Height this way:

double twoThird = (double) panel.Width * 0.66;

but I got an error saying that the compiler cannot cast Unit.Pixel to
double. Ok I understand I cannot cast an object to a type value. But
converto to string and follow convert to double just to store in a
double variable seems to me to much work for nothing.

Can anyone tell if there's a simpler way to do this?

Thanks

Nov 15 '05 #2
Hi Xiko,

Are you generating your table dinamically? if so you could use the
Attributes property of the HtmlTableCell to set the width from the client
view, in such a way you could do something like:
htmltablecell_1 .Attributes.Add ( "width", "33%");
htmltablecell_2 .Attributes.Add ( "width", "67%");

I haven't tested it but I think it could work.

in this way you could avoid setting the value in pixels
Hope this help,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"xiko tripa" <xi*******@bol. com.br> wrote in message
news:3d******** *************** ***@posting.goo gle.com...
Hi. I have an apsx page with a Panel inside. The panel has his
properties Width and Height set to 590 and 390 respectively.

I call a function to make up an table inside this panel. That table
has 2 columns. The size of the first one has 2/3 of the panel.width
and the size of the second one has 1/3 of the panel.width.

The only way I got to calculate these values was:

private void MakeCentralTabl e(Panel panel)
{
double twoThird = double.Parse(pa nel.Width.ToStr ing()) * 0.66;
double oneThird = double.Parse(pa nel.Width.ToStr ing()) * 0.33;
double half = double.Parse(pa nel.Height.ToSt ring()) * 0.5;

First I tryied to convert panel.Width and .Height this way:

double twoThird = (double) panel.Width * 0.66;

but I got an error saying that the compiler cannot cast Unit.Pixel to
double. Ok I understand I cannot cast an object to a type value. But
converto to string and follow convert to double just to store in a
double variable seems to me to much work for nothing.

Can anyone tell if there's a simpler way to do this?

Thanks

Nov 15 '05 #3
Hello Nicholas

Yes you're right, I could use the Percentage method. But my question
is about how to store width and height values into variables for use
to other purposes later.

I'm wondering how to cast Unit.xxx() values to some type variable in
order to store and recover these values sometime in code execution for
some reason, and I didn't find how to do that.

Excuse me my bad English, it's not my first language. I'm trying to do
my best to be understandable.

Thanks

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c om> wrote in message news:<#Y******* *******@tk2msft ngp13.phx.gbl>. ..
xiko,

Instead of using actual pixels (or some other absolute unit, which
really isn't a good way to do it), why not set the Width property to a Unit
which was generated using the static Percentage method on the Unit
structure? The width of a panel is in units, and that is a combination of a
number, and a unit of measurement.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"xiko tripa" <xi*******@bol. com.br> wrote in message
news:3d******** *************** ***@posting.goo gle.com...
Hi. I have an apsx page with a Panel inside. The panel has his
properties Width and Height set to 590 and 390 respectively.

I call a function to make up an table inside this panel. That table
has 2 columns. The size of the first one has 2/3 of the panel.width
and the size of the second one has 1/3 of the panel.width.

The only way I got to calculate these values was:

private void MakeCentralTabl e(Panel panel)
{
double twoThird = double.Parse(pa nel.Width.ToStr ing()) * 0.66;
double oneThird = double.Parse(pa nel.Width.ToStr ing()) * 0.33;
double half = double.Parse(pa nel.Height.ToSt ring()) * 0.5;

First I tryied to convert panel.Width and .Height this way:

double twoThird = (double) panel.Width * 0.66;

but I got an error saying that the compiler cannot cast Unit.Pixel to
double. Ok I understand I cannot cast an object to a type value. But
converto to string and follow convert to double just to store in a
double variable seems to me to much work for nothing.

Can anyone tell if there's a simpler way to do this?

Thanks

Nov 15 '05 #4
Hi Ignacio

Thanks for your reply. Please, see my reply to Nicholas.

Thanks
"Ignacio Machin \( .NET/ C# MVP \)" <ignacio.mach in AT dot.state.fl.us > wrote in message news:<Oj******* *******@TK2MSFT NGP09.phx.gbl>. ..
Hi Xiko,

Are you generating your table dinamically? if so you could use the
Attributes property of the HtmlTableCell to set the width from the client
view, in such a way you could do something like:
htmltablecell_1 .Attributes.Add ( "width", "33%");
htmltablecell_2 .Attributes.Add ( "width", "67%");

I haven't tested it but I think it could work.

in this way you could avoid setting the value in pixels
Hope this help,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"xiko tripa" <xi*******@bol. com.br> wrote in message
news:3d******** *************** ***@posting.goo gle.com...
Hi. I have an apsx page with a Panel inside. The panel has his
properties Width and Height set to 590 and 390 respectively.

I call a function to make up an table inside this panel. That table
has 2 columns. The size of the first one has 2/3 of the panel.width
and the size of the second one has 1/3 of the panel.width.

The only way I got to calculate these values was:

private void MakeCentralTabl e(Panel panel)
{
double twoThird = double.Parse(pa nel.Width.ToStr ing()) * 0.66;
double oneThird = double.Parse(pa nel.Width.ToStr ing()) * 0.33;
double half = double.Parse(pa nel.Height.ToSt ring()) * 0.5;

First I tryied to convert panel.Width and .Height this way:

double twoThird = (double) panel.Width * 0.66;

but I got an error saying that the compiler cannot cast Unit.Pixel to
double. Ok I understand I cannot cast an object to a type value. But
converto to string and follow convert to double just to store in a
double variable seems to me to much work for nothing.

Can anyone tell if there's a simpler way to do this?

Thanks

Nov 15 '05 #5

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

Similar topics

3
11754
by: dave | last post by:
Hello there, I am at my wit's end ! I have used the following script succesfully to upload an image to my web space. But what I really want to be able to do is to update an existing record in a table in MySQL with the path & filename to the image. I have successfully uploaded and performed an update query on the database, but the problem I have is I cannot retain the primary key field in a variable which is then used in a SQL update...
0
1608
by: maceo | last post by:
I have some code that extracts the data from a table and performs a calculation (total time) on one of the columns. Here is the code: <?php /* Database connection */
2
9300
by: bissatch | last post by:
Hi, I am trying to write script that is run when a form is submitted. The form contains an image input field and when submitted, the image is uploaded, resized and added as binary information to a db table. Please note, I am using a PostgreSQL database I have written all the code out below that deals with the submission processing:
1
3172
by: Quentin | last post by:
hey there, ok i made a class, that inherits webcontrol, and i add an htmltable to it. I was wondering how to declare an ascx file as an object in my class, like that i could change the content (the ascx file) of a cell thanks to a property and it would be great :) Merci d'avance pour l'aide :)
0
1591
by: Lucas, Todd | last post by:
Hello everyone! I'm having a problem with a WebControl that I'm designing for a Menu. I've been at it for about 3 weeks now, and can't seem to get around this problem. So I'm hoping that someone can help me ... My environment: VS 2003 v7.1.3088, Win2K v5.0.2195 SP3, IE6 v6.0.2800.1106 browser. I have a class (C3Menu) derived from WebControl, with a property (MenuItems) that is a collection of menu items. The collection property is...
1
1425
by: Sam Collett | last post by:
How would you go about create a web control that allows you to upload images and limit the dimensions (width/height) of the image? The control may be put on any page, which may not contain the correct EncType (multipart/form-data), so I would want it to set the EncType of the form. Can a control be done that extends on an already existing control - the one I have in mind is MetaBuilder FileUpload control...
0
2021
by: Dariusz Tomon | last post by:
Hi I have got the problem with web control displaying flash (swf) object. The problem is connected with the fact that 1-st swf should loads the second one. But it doesn't. That's why I suspects taht webcontrol or class under it causes that problem. Maybe the following code is too long to analyze so pls redirect me whare I could read/download the code suitable for that purposes.
6
2524
by: Dave Harvey | last post by:
I have developed a standard .NET control which displays medical images and works fine in applications, but increasingly, my customers are wishing to use it in an ASP.NET environment, so I am looking to make a WebControl based equivalent. So, assuming that I need to render using HTML - how can I pass "bitmap" data into such a control for it to be displayed. I'm open to all possible routes, but I've not yet found one which works. Ideas...
0
863
by: rrutkowski | last post by:
Hi! I have the following situation public class Class1 : WebControl { public Class1() : base(HtmlTextWriterTag.Div) { }
0
8465
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8809
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8588
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7407
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6210
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4206
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4386
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2032
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1788
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.