473,386 Members | 1,791 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,386 software developers and data experts.

Storing WebControl.Width and WebControl.Height 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 MakeCentralTable(Panel panel)
{
double twoThird = double.Parse(panel.Width.ToString()) * 0.66;
double oneThird = double.Parse(panel.Width.ToString()) * 0.33;
double half = double.Parse(panel.Height.ToString()) * 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 5589
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.com

"xiko tripa" <xi*******@bol.com.br> wrote in message
news:3d**************************@posting.google.c om...
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 MakeCentralTable(Panel panel)
{
double twoThird = double.Parse(panel.Width.ToString()) * 0.66;
double oneThird = double.Parse(panel.Width.ToString()) * 0.33;
double half = double.Parse(panel.Height.ToString()) * 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.google.c om...
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 MakeCentralTable(Panel panel)
{
double twoThird = double.Parse(panel.Width.ToString()) * 0.66;
double oneThird = double.Parse(panel.Width.ToString()) * 0.33;
double half = double.Parse(panel.Height.ToString()) * 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.com> wrote in message news:<#Y**************@tk2msftngp13.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.com

"xiko tripa" <xi*******@bol.com.br> wrote in message
news:3d**************************@posting.google.c om...
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 MakeCentralTable(Panel panel)
{
double twoThird = double.Parse(panel.Width.ToString()) * 0.66;
double oneThird = double.Parse(panel.Width.ToString()) * 0.33;
double half = double.Parse(panel.Height.ToString()) * 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.machin AT dot.state.fl.us> wrote in message news:<Oj**************@TK2MSFTNGP09.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.google.c om...
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 MakeCentralTable(Panel panel)
{
double twoThird = double.Parse(panel.Width.ToString()) * 0.66;
double oneThird = double.Parse(panel.Width.ToString()) * 0.33;
double half = double.Parse(panel.Height.ToString()) * 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
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...
0
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
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...
1
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...
0
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...
1
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...
0
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...
6
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...
0
by: rrutkowski | last post by:
Hi! I have the following situation public class Class1 : WebControl { public Class1() : base(HtmlTextWriterTag.Div) { }
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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:
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...

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.