Showing posts with label width. Show all posts
Showing posts with label width. Show all posts

Wednesday, March 28, 2012

text control as hidden field?

hello
I would like to have text control "appear" as hidden on the page. Now the only way to make it invisible is to set its width and height to zero or set special style.
I tried to change the atribute "type" to "hidden" but then i always have both types: "text" and "hidden" even if i run Attributes.Clear() method before i render.
PS. I add the control dynamically in code , not on the design screen.

Regards
Pawel Palasz
pawel.palasz@dotnet.itags.org.echarris.comIf you're talking about the ASP.Net Textbox - - it has a Visible property - - just set it to False or True whenever you'd like, in your code.
Try this one


<asp:TextBox id="TextBox1" style="Z-INDEX: 101; LEFT: 94px; POSITION: absolute; TOP: 98px;" runat="server"></asp:TextBox>

And from the code behind simply set the "display" style of the TextBox


TextBox1.Style.Item("display") = "none"

text controls, when they change update the total control

I have 4 text field server controls formatted in currency like $1.00 like this one called Mastercard:


<td width="130" style="WIDTH: 130px">Mastercard
</td>
<td width="21" style="WIDTH: 21px"><INPUT onkeypress="return(currencyFormatCents(this,',','.','$',event))" id="Mastercard" type="text" name="Mastercard" runat="server" style="WIDTH: 116px; HEIGHT: 22px" size="14"></td>

When This control, or any of the other 4 I want to update a label control with their total (all 4 added together).


<DIV id=TotalCreditCards
style="DISPLAY: inline; WIDTH: 70px; HEIGHT: 15px"
ms_positioning="FlowLayout"></DIV></TD>

Thank you for any helpI would put a routine in the onkeypress method to add the values together and display them on the label.
What if I have a routine already in the onkeypress, how can I add another one. Or is there a method for when you leave the text field?
Please take a look at this code. I get 'object expected' error on the page as soon as I update the Lottery text field that does onblur="CreateTotal" If I take out it out then I do not get the error.

Dim Section1Total as Decimal
Sub CreateTotal()
Section1Total = Lottery.Value + DriveOff.Value + drawer.Value + Other.Value
page.DataBind
End sub

If the below text field changes then I want Section1Total to be updated.


<INPUT onblur="CreateTotal" onkeypress="return(currencyFormatCents(this,',','.','$',event))" id="Lottery" type="text" name="Lottery" runat="server" style="WIDTH: 116px; HEIGHT: 22px" size="14"></TD>

Then this is the label that Section1Total goes into:


<asp:label id="Total" runat="server"
Text= '<%# Section1Total %>' Width="110px" Height="13px">

Change this:


Sub CreateTotal()
Section1Total = Lottery.Value + DriveOff.Value + drawer.Value + Other.Value
page.DataBind
End sub

To:


Sub CreateTotal(ByVal sender As System.Object, ByVal e As System.EventArgs)
Section1Total = Lottery.Value + DriveOff.Value + drawer.Value + Other.Value
page.DataBind
End sub

Then try executing hte onblur="CreateTotal" again.

And make sure you declared all your form variables properly:


Lottery.Value + DriveOff.Value + drawer.Value + Other.Value

I am assuming they are textbox controls, so they need to be declared by using:


Protected WithEvents DriveOff As System.Web.UI.WebControls.TextBox
Protected WithEvents Lottery As System.Web.UI.WebControls.TextBox
Protected WithEvents drawer As System.Web.UI.WebControls.TextBox
Protected WithEvents OtherAs System.Web.UI.WebControls.TextBox

HTH
Ah, just noticed you were using an HTML text control and not a web control. In that case you must declare them by using the following:


Protected WithEvents DriveOff As System.Web.UI.HtmlControls.HtmlInputText
Protected WithEvents Lottery As System.Web.UI.HtmlControls.HtmlInputText
Protected WithEvents drawer As System.Web.UI.HtmlControls.HtmlInputText
Protected WithEvents OtherAs As System.Web.UI.HtmlControls.HtmlInputText

It already said that my HTML text controls were declared, so I did not include those lines of code but the rest I did word for word. I even added a button and have the onclick="CreateTotal"

Here is my vbscript

Sub CreateTotal(ByVal sender As System.Object, ByVal e As System.EventArgs)

Section1Total = Lottery.Value + DriveOff.Value + drawer.Value + Other.Value
page.DataBind

End sub

and the other Lottery control has


<INPUT onblur="CreateTotal" onkeypress="return(currencyFormatCents(this,',','.','$',event))" id="Lottery" style="WIDTH: 116px; HEIGHT: 22px" type="text" size="14" value="0" name="Lottery" runat="server"></TD>

When I click off Lottery textbox I get
Line: 507
Char: 1
Error 'CreateTotal' is undefined

when I click on the button I get the same error. Line 507 - doesn't not point to the correct place where 'CreateTotal' was called.

Thanks for the suggestions, any other ideas.
Can you post line 507?

Text element's width is too wide when doctype is set to XHTML

I've read a bunch of posts on this and none of the answers are
legitimate (IMHO) so I thought I'd throw it out there again.

Using the html code below, if you set the doctype to HTML 4.0, and
view the page in IE 6 or 7, the text element fills the table cell
perfectly.
If you change the doctype to XHTML 1.0, the text element extends
beyond the width of the table cell.
On the other hand, if you view the page in FireFox, the page displays
perfectly regardless of which doctype you use.

I'm really looking for a better solution than to set the doctype to
HTML 4.0. Or perhaps is this just another anomaly in IE?

Please note that I have included both doc type headers. The first
doctype header is always used so just reverse the order to try each
one out.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml">
<body>
<table>
<tr>
<td width="200">
<input type="text" style="width:100%" />
</td>
</tr>
</table>
</body>
</html>you just need to understand html 4.0. object have a width, border and
margin. the border and margin extend beyond the width. so if you make an
object 100px wide with a 2px margin and a 2px border it will be 108px
wide. if you make the width 100% (of the parent), with margin and border
it will be 8px wider than the parent. now if the parent has padding the
control is offset and will extend beyond the parent unless overflow is set.

because you are not setting the borders, margins, and padding, you get
the default, which differs by browser.

-- bruce (sqlwork.com)

mszanto@.hotmail.com wrote:

Quote:

Originally Posted by

I've read a bunch of posts on this and none of the answers are
legitimate (IMHO) so I thought I'd throw it out there again.
>
Using the html code below, if you set the doctype to HTML 4.0, and
view the page in IE 6 or 7, the text element fills the table cell
perfectly.
If you change the doctype to XHTML 1.0, the text element extends
beyond the width of the table cell.
On the other hand, if you view the page in FireFox, the page displays
perfectly regardless of which doctype you use.
>
I'm really looking for a better solution than to set the doctype to
HTML 4.0. Or perhaps is this just another anomaly in IE?
>
Please note that I have included both doc type headers. The first
doctype header is always used so just reverse the order to try each
one out.
>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml">
<body>
<table>
<tr>
<td width="200">
<input type="text" style="width:100%" />
</td>
</tr>
</table>
</body>
</html>
>


I've done a bit more research, and understand what you mean, but that
that really only applies for XHTML doctypes. HTML doc types
automatically take these other factors into account when determining
the display width of an object whose style width is set to 100%.

Apparently XHTML uses a strict box model which really causes a lot of
aggravation when laying out a web page. Another example being that you
can't set the height of a Table inline, you have to set it in the
style sheet. I'm okay with that as long as the XHTML doctype is used
in the appropriate situations.

Having said all that, why oh why did Microsoft decide to set the
default doctype to XHTML for new WebForms in VS 2005. That is
completely idiotic considering the aggravation it will cause for the
majority of developers.

mike

Text element's width is too wide when doctype is set to XHTML

I've read a bunch of posts on this and none of the answers are
legitimate (IMHO) so I thought I'd throw it out there again.
Using the html code below, if you set the doctype to HTML 4.0, and
view the page in IE 6 or 7, the text element fills the table cell
perfectly.
If you change the doctype to XHTML 1.0, the text element extends
beyond the width of the table cell.
On the other hand, if you view the page in FireFox, the page displays
perfectly regardless of which doctype you use.
I'm really looking for a better solution than to set the doctype to
HTML 4.0. Or perhaps is this just another anomaly in IE?
Please note that I have included both doc type headers. The first
doctype header is always used so just reverse the order to try each
one out.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml">
<body>
<table>
<tr>
<td width="200">
<input type="text" style="width:100%" />
</td>
</tr>
</table>
</body>
</html>you just need to understand html 4.0. object have a width, border and
margin. the border and margin extend beyond the width. so if you make an
object 100px wide with a 2px margin and a 2px border it will be 108px
wide. if you make the width 100% (of the parent), with margin and border
it will be 8px wider than the parent. now if the parent has padding the
control is offset and will extend beyond the parent unless overflow is set.
because you are not setting the borders, margins, and padding, you get
the default, which differs by browser.
-- bruce (sqlwork.com)
mszanto@.hotmail.com wrote:
> I've read a bunch of posts on this and none of the answers are
> legitimate (IMHO) so I thought I'd throw it out there again.
> Using the html code below, if you set the doctype to HTML 4.0, and
> view the page in IE 6 or 7, the text element fills the table cell
> perfectly.
> If you change the doctype to XHTML 1.0, the text element extends
> beyond the width of the table cell.
> On the other hand, if you view the page in FireFox, the page displays
> perfectly regardless of which doctype you use.
> I'm really looking for a better solution than to set the doctype to
> HTML 4.0. Or perhaps is this just another anomaly in IE?
> Please note that I have included both doc type headers. The first
> doctype header is always used so just reverse the order to try each
> one out.
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
> www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
> <html xmlns="http://www.w3.org/1999/xhtml">
> <body>
> <table>
> <tr>
> <td width="200">
> <input type="text" style="width:100%" />
> </td>
> </tr>
> </table>
> </body>
> </html>
>
I've done a bit more research, and understand what you mean, but that
that really only applies for XHTML doctypes. HTML doc types
automatically take these other factors into account when determining
the display width of an object whose style width is set to 100%.
Apparently XHTML uses a strict box model which really causes a lot of
aggravation when laying out a web page. Another example being that you
can't set the height of a Table inline, you have to set it in the
style sheet. I'm okay with that as long as the XHTML doctype is used
in the appropriate situations.
Having said all that, why oh why did Microsoft decide to set the
default doctype to XHTML for new WebForms in VS 2005. That is
completely idiotic considering the aggravation it will cause for the
majority of developers.
mike

Monday, March 26, 2012

text length in pixels

Hi,

I am trying to resolve the following scenario:
We have a text box of fixed width that by default should display only 1 line
of text without a scrollbar indicator.
If there are multiple lines of text then we need to to indicate that by
displaying a button alongside the textbox that the user can click on to
expand the height of the text box. The height would be, say, 4 lines of
text. If there are more than 4 lines of text then we need to display a
vertical scrollbar.
To be able to achieve this, it seems, we need to be able to compare the
length of the text with that of the textbox. If we can somehow get the
length in pixels that would solve part of the problem?

Any ideas would be greatly appreciated...

Thanks, VishalInstead of trying to accomplish this by pixels (the hard way), try this:

A textbox that does not have any styling applied to it will use a font where
different characters are different widths (capital W is wider than lower
case l). So, pick a number of characters that you consider to be one full
line of text. You can programmatically check the number of characters in a
textbox and when you reach your one line limit, you can change the rows
property of the textbox to 4. The vertical scroll bar is built in, so you
don't have to worry about enabling it when needed.

"Vishal Gupta" <vishalg_99@.hotmail.com> wrote in message
news:eqX6Zmr3DHA.2112@.TK2MSFTNGP10.phx.gbl...
> Hi,
> I am trying to resolve the following scenario:
> We have a text box of fixed width that by default should display only 1
line
> of text without a scrollbar indicator.
> If there are multiple lines of text then we need to to indicate that by
> displaying a button alongside the textbox that the user can click on to
> expand the height of the text box. The height would be, say, 4 lines of
> text. If there are more than 4 lines of text then we need to display a
> vertical scrollbar.
> To be able to achieve this, it seems, we need to be able to compare the
> length of the text with that of the textbox. If we can somehow get the
> length in pixels that would solve part of the problem?
> Any ideas would be greatly appreciated...
> Thanks, Vishal
Check out the .NET Framework Class Library for:

Graphics.MeasureString Method (String, Font)

"Scott M." <s-mar@.BADSPAMsnet.net> wrote in message
news:%233OjMrr3DHA.3656@.TK2MSFTNGP11.phx.gbl...
> Instead of trying to accomplish this by pixels (the hard way), try this:
> A textbox that does not have any styling applied to it will use a font
where
> different characters are different widths (capital W is wider than lower
> case l). So, pick a number of characters that you consider to be one full
> line of text. You can programmatically check the number of characters in
a
> textbox and when you reach your one line limit, you can change the rows
> property of the textbox to 4. The vertical scroll bar is built in, so you
> don't have to worry about enabling it when needed.
>
> "Vishal Gupta" <vishalg_99@.hotmail.com> wrote in message
> news:eqX6Zmr3DHA.2112@.TK2MSFTNGP10.phx.gbl...
> > Hi,
> > I am trying to resolve the following scenario:
> > We have a text box of fixed width that by default should display only 1
> line
> > of text without a scrollbar indicator.
> > If there are multiple lines of text then we need to to indicate that by
> > displaying a button alongside the textbox that the user can click on to
> > expand the height of the text box. The height would be, say, 4 lines of
> > text. If there are more than 4 lines of text then we need to display a
> > vertical scrollbar.
> > To be able to achieve this, it seems, we need to be able to compare the
> > length of the text with that of the textbox. If we can somehow get the
> > length in pixels that would solve part of the problem?
> > Any ideas would be greatly appreciated...
> > Thanks, Vishal

Thursday, March 22, 2012

Textareas Height and Width not Sent to Firefox

Hello:

When my web application is invoked by Firefox the height and width
information is passed to Internet Explorer but not to Firefox.

The ASP.NET control is
<asp:textbox id="tbxNote" runat="server" Width="100%" Height="226px"
TextMode="MultiLine">
For IE it renders
<textarea name="tbxNote" id="tbxNote" style="height:226px;width:100%;">
For Firefix it renders
<textarea name="tbxNote" id="tbxNote"
Is there something I can do to induce ASP.NET to pass the style information
to Firefox?

I will be very grateful for your help.Hi,

you need just tweak browser detection within config files so that FireFox is
recognized better.
http://weblogs.mozillazine.org/gerv...ves/008336.html

--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke
set rows and columns for w3c compliance

"honcho" <goaway@.nospam.com> wrote in message
news:1121195322.46481282447c7dd42a8bb382e8a6d776@.b ubbanews...
> Hello:
> When my web application is invoked by Firefox the height and width
> information is passed to Internet Explorer but not to Firefox.
> The ASP.NET control is
> <asp:textbox id="tbxNote" runat="server" Width="100%" Height="226px"
> TextMode="MultiLine">
> For IE it renders
> <textarea name="tbxNote" id="tbxNote" style="height:226px;width:100%;">
> For Firefix it renders
> <textarea name="tbxNote" id="tbxNote">
> Is there something I can do to induce ASP.NET to pass the style
> information to Firefox?
> I will be very grateful for your help.
That was a very useful suggestion. Thank you.

"TJS" <nospam@.here.com> wrote in message
news:ee$JcDyhFHA.1968@.TK2MSFTNGP14.phx.gbl...
> set rows and columns for w3c compliance
>
> "honcho" <goaway@.nospam.com> wrote in message
> news:1121195322.46481282447c7dd42a8bb382e8a6d776@.b ubbanews...
>> Hello:
>>
>> When my web application is invoked by Firefox the height and width
>> information is passed to Internet Explorer but not to Firefox.
>>
>> The ASP.NET control is
>> <asp:textbox id="tbxNote" runat="server" Width="100%" Height="226px"
>> TextMode="MultiLine">
>> For IE it renders
>> <textarea name="tbxNote" id="tbxNote" style="height:226px;width:100%;">
>> For Firefix it renders
>> <textarea name="tbxNote" id="tbxNote">
>>
>> Is there something I can do to induce ASP.NET to pass the style
>> information to Firefox?
>>
>> I will be very grateful for your help.
>>