Showing posts with label instead. Show all posts
Showing posts with label instead. Show all posts

Saturday, March 31, 2012

Text Box and Image Button

Hello,

I added a TextBox and an Image Button to a page so that they are side
by side.
Instead of both being top aligned the Text Box is pushed down.

Why is that?
How can I solve this?

Thanks,
MiguelHi there again,

<asp:ImageButton ID="ImageButton1" runat="server" ImageAlign="Top" />
<asp:TextBox ID="TextBox2" runat="server" />

or

<table>
<tr>
<td valign="top">
<asp:ImageButton ID="ImageButton2" runat="server" />
</td>
<td valign="top">
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</td>
</tr>
</table>

or

<div>
<div style="float:left">
<asp:ImageButton ID="ImageButton3" runat="server" />
</div>
<asp:TextBox ID="TextBox3" runat="server" />
</div>
--
Milosz

"shapper" wrote:

Quote:

Originally Posted by

Hello,
>
I added a TextBox and an Image Button to a page so that they are side
by side.
Instead of both being top aligned the Text Box is pushed down.
>
Why is that?
How can I solve this?
>
Thanks,
Miguel
>
>

Text Box and Image Button

Hello,
I added a TextBox and an Image Button to a page so that they are side
by side.
Instead of both being top aligned the Text Box is pushed down.
Why is that?
How can I solve this?
Thanks,
MiguelHi there again,
<asp:ImageButton ID="ImageButton1" runat="server" ImageAlign="Top" />
<asp:TextBox ID="TextBox2" runat="server" />
or
<table>
<tr>
<td valign="top">
<asp:ImageButton ID="ImageButton2" runat="server" />
</td>
<td valign="top">
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</td>
</tr>
</table>
or
<div>
<div style="float:left">
<asp:ImageButton ID="ImageButton3" runat="server" />
</div>
<asp:TextBox ID="TextBox3" runat="server" />
</div>
--
Milosz
"shapper" wrote:

> Hello,
> I added a TextBox and an Image Button to a page so that they are side
> by side.
> Instead of both being top aligned the Text Box is pushed down.
> Why is that?
> How can I solve this?
> Thanks,
> Miguel
>

Text Box cocatenating instead of adding

When I run this line of code, I'm getting 444 instead of 12:
lblWkTotal1.text = lblSatTotal.text + lblSunTotal.text + lblMonTotal.text + lblTueTotal.text + lblWedTotal.text + lblThuTotal.text + lblFriTotal.text
If I run this line of code, I'm getting this error message: Cast from string "" to type 'Decimal' is not valid.
lblWkTotal1.text = CDec(lblSatTotal.text) + CDec(lblSunTotal.text) + CDec(lblMonTotal.text) + CDec(lblTueTotal.text) + CDec(lblWedTotal.text) + CDec(lblThuTotal.text) + CDec(lblFriTotal.text)
Any ideas how to correct the problem.
Thanks

Try changing from cDec to cDbl


Hi

Try usingCInt(TxtboxName.text).


Thanks David
When I change it to CDbl the followuing messages are generated:
[FormatException: Input string was not in a correct format.]
[InvalidCastException: Cast from string "" to type 'Double' is not valid.]
Any ideas where to go from here?
Franco

David
Changing to CDbl works OK if I first set the default text to 0.
Thanks for the suggestion.
Franco

Try forcing the result to a string
textBox.Text = CStr(Cint(blah) + CInt(Blah))
or
Dim i as Int32
i = CInt(Blah) + ...
textBox.Text = i.ToString()

Tuesday, March 13, 2012

Textbox and its corresponding submit button.

I noticed that if I hit enter in the text box instead of clicking on the submit button that the page just refreshes and bttn_click event doesn't occur for the submittal.

After a search I found the following to work:

ClientScript.RegisterHiddenField(string hiddenFieldName, string hiddenFieldInitialValue)

From what I gather this allows the page to have a default button event occur whenever the enter key is pressed in a text box.

My question is how would you go about setting this up for more than one text box and submit button on a page that will do different things other than the default.

I found this:
this.userTxtBx.Attributes.Add("onkeypress", "setEnterKey('userBttn')");
but it does not work in my attempts.

Thanks in advance.After contemplating the problem further, I realize the problem is not so complex.
The simplest solution is html form code defaultbutton=""
Another way is to have a hidden textbox field in your form.

Read this too
http://aspnet.4guysfromrolla.com/articles/060805-1.aspx
Thank you for this.

TextBox and ImageButton

Hello,

I added a TextBox and an Image Button to a page so that they are side by side.
Instead of both being top aligned the Text Box is pushed down.

Why is that?
How can I solve this?

Thanks,
Miguel

Insert a table of 1 row, 2 columns (I do it from the Layout menu)

Put the TextBox in one cell, the Image Button in the other.

You may have to play with the cell alignments to get it to look the way you want.


Tables are the easiest way to handle controlling the layout of your page. If you're not going to use css to control your layout, you'll need to use tables. Good Luck!

Hi,

I don't use tables. I always use CSS for layouts.

Anyway, I was able to solve it. Just set my ImageButton's ImageAlign property to Top and everything went fine.

Thanks,

Miguel


Great, css is far better for your work. Good Luck

shapper:

Hi,

I don't use tables. I always use CSS for layouts.

Anyway, I was able to solve it. Just set my ImageButton's ImageAlign property to Top and everything went fine.

Thanks,

Miguel

I just recently learned an even easier way to control your layout. Go to the layout tab, then go to position > auto-position options > then check the checkbox for changing position for controls added.

That should really spice things up for ya, good luck!

Textbox array?

I've started using VB.net instead of VB6. I'm missing the possiblity of making textboxes as an array. In VB6 this is standard, but is it possible at all in VB.Net?There are no control arrays in .net like there was in VB6.

What is it your trying to do?
to make a control array in .NET you create for example 3 textboxes named text1,text2,text3 respectively. Then in the text1 change event(Or any event) where it says Handles you append the extra textbox names and events.

Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged, TextBox2.TextChanged, TextBox3.TextChanged

I havnet figured out how to detect which textbox was used, but this fires the event for all 3 textboxes.
I havnet figured out how to detect which textbox was used, but this fires the event for all 3 textboxes.

The way to figure out which one is to cast the sender object to a textbox, then refer to the senders name.

Dim myTextBox As TextBox
myTextBox = CType(sender, TextBox)

If myTextBox.Name = TextBox1 Then
' Do your processing for textbox 1.
End If

If myTextBox.Name = TextBox2 Then
' Do your processing for textbox 2.
End If
I have a this sub:

Private Sub btnNulstil_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNulstil.Click
txtKar1.Text = ""
txtKar2.Text = ""
txtKar3.Text = ""
txtKar4.Text = ""
txtKar5.Text = ""
End Sub

Imagine that I had 100 text boxes, I would'nt like to write the lines txtKarX.text ="" up to 100. How can I make this in a smart way?
good question.. and i have no earthly idea why microsoft got rid of control arrays.

But i would think you would loop thru them using some sort of Object collection thingy.