Saturday, March 31, 2012
Text Box Values in Repeater being Added on Input
I have an existing repeater on my web application that has descriptions, item numbers, and prices. The marketing person at my company wants me to add a field so that the sales people can enter discounted prices next to the regular prices. So I'm going to have to add a asp:textbox to the repeater.
What would be the easiest way of adding text fields in the repeater so that when there is input the values would add up in a label. I won't know how many items there will be in the repeater.
I'll probably need to write some javascript for this but I'm wondering what the best way of doing this is?
Thanks!
JamesIt might help if I knew how to check to see if a control exists or not? Anyone know?
The repeater should have a .Controls property with a .Length or .Count. (Count, I beleive).
From there, just start a standard FOR loop and check each control. The .ToString on the control indexer (myRepeater.Controls[i].ToString()) will tell you what TYPE of control it is. Only check the textbox types...
Saturday, March 24, 2012
Text Masking
String formatting in C# (http://www.stevex.org/CS/blogs/dottext/articles/158.aspx) -> C# article but still applies to VB.NET. It even has an example for phone numbers!
HTH
DJ
Thanks, that helps on the output. Still looking for thoughts on Input Masking as well. I've converting an old Access App to a SQL/ASP.NET app, and alot of the fields were masked to a certain input. I can do regular expression validators, but what a hassle to right them for every input and even then it doesn't seem as intuitive.
Could you give some more details of what you are doing - I don't understand why the above wouldn't work for the situation you describe. Perhaps I've misunderstood.
DJ
No, that will work great for when I output from the database. I'm just trying to figure out a way to mask data on input. For example, in this Access app I am converting to ASP.NET, for a phone number, it has an text field that looks something like: (___) ___-____ , where it restricts (masks) input.
Your best bet is to use javascript. I don't know if you are good with JS or not, but I am sure you could find sample code for formatting a phone number using it.
I recommend this because it will be 100% client side formatting, and won't be a drag on your webserver. If you were to make the input box run at the server, and put code in its textchanged event, each time they type a number in the box it would post back to your webserver. Javascript will simply do everything client side. it would be the onchange event of the input tag that you would want to perform the formatting. Basically you look at the entered string, get all the numbers in it, and if the numbers length is 10, then you have potentially a valid phone number and should format it, otherwise do not.
Thursday, March 22, 2012
textbox
I need a text box the enables input numbers from right to left. does any
know of such a control?
yoramo.You can achieve this through css:
Put the following between the <HEAD></HEAD> tags in your html view. ( or use
a style sheet )
<style>
..sample {text-align: right;}
</style
In the designer, assign the textbox's "CssClass" = sample;
You should be good to go.
David Young
"yoramo" <yoramo@.[NOSPAM]hotmail.com> wrote in message
news:OGHAhi17DHA.1596@.TK2MSFTNGP10.phx.gbl...
> hello
> I need a text box the enables input numbers from right to left. does any
> know of such a control?
> yoramo.
thats not what i need.
i need to be able to key in numbers from right to left.
example: "123" should be key in '3','2','1'
"dm_dal" <REMOVE_THIS.dmy75252@.yahoo.com> wrote in message
news:eigBSu17DHA.2416@.TK2MSFTNGP10.phx.gbl...
> You can achieve this through css:
> Put the following between the <HEAD></HEAD> tags in your html view. ( or
use
> a style sheet )
> <style>
> .sample {text-align: right;}
> </style>
> In the designer, assign the textbox's "CssClass" = sample;
> You should be good to go.
> David Young
> "yoramo" <yoramo@.[NOSPAM]hotmail.com> wrote in message
> news:OGHAhi17DHA.1596@.TK2MSFTNGP10.phx.gbl...
> > hello
> > I need a text box the enables input numbers from right to left. does any
> > know of such a control?
> > yoramo.
Ok...you want to reverse the order in which the values are typed in?
Let me chew on that a little and I'll get back with you.
David Young
"yoramo" <yoramo@.[NOSPAM]hotmail.com> wrote in message
news:elwLh217DHA.3380@.tk2msftngp13.phx.gbl...
> thats not what i need.
> i need to be able to key in numbers from right to left.
> example: "123" should be key in '3','2','1'
>
> "dm_dal" <REMOVE_THIS.dmy75252@.yahoo.com> wrote in message
> news:eigBSu17DHA.2416@.TK2MSFTNGP10.phx.gbl...
> > You can achieve this through css:
> > Put the following between the <HEAD></HEAD> tags in your html view. ( or
> use
> > a style sheet )
> > <style>
> > .sample {text-align: right;}
> > </style>
> > In the designer, assign the textbox's "CssClass" = sample;
> > You should be good to go.
> > David Young
> > "yoramo" <yoramo@.[NOSPAM]hotmail.com> wrote in message
> > news:OGHAhi17DHA.1596@.TK2MSFTNGP10.phx.gbl...
> > > hello
> > > > I need a text box the enables input numbers from right to left. does
any
> > > know of such a control?
> > > > yoramo.
> >
You may need to create a custom textbox that does some JavaScript
manipulation on the client side. Handling the key events and adding the new
keystroke to the beginning of the existing string. Not being a guru at
JavaScript I can't give you details, but the concept should hold.
-- Jim --
"yoramo" <yoramo@.[NOSPAM]hotmail.com> wrote in message
news:OGHAhi17DHA.1596@.TK2MSFTNGP10.phx.gbl...
> hello
> I need a text box the enables input numbers from right to left. does any
> know of such a control?
> yoramo.
Tuesday, March 13, 2012
TextBox & label Bug
I am not able to align the numbers displayed in a textbox or a label to right side.
It is terrible problem and spent 2 hours in resolving the problem
Instead of displaying Values in the textbox or label i directly displayed in the table with right align.
Now it was working properly but every time the post back happens the values get empty
Please help to solve the problem. It urgent.
Hi,
have you tried just doing it like this
<asp:TextBox ID="TextBox1" runat="server" Text="text in TextBox"style="text-align:right" Width="200" /><br />
<asp:Label ID="Label1" runat="server" Text="text in Label"style="text-align:right" Width="200" />
Should work fine. Can you clarify what you mean by values getting empty after postback? How have you declared the controls and where do you assign the Text?
I did not get this idea.
Thanks.
I created some variables in the code file and i called this variables using <%= txtname %>
the values are getting empty when the postback happens, i have declared the variables
below the class file ?
What should i do to retain the values ?
2. I want to format the numbers like ##,##,##,###.00 ?. I have given it but the numbers
are not getting formatted in the textbox .
Wow, it's amazing how people with no clue cry out "bug in the system!" so easily
i was of thinking of windows forms where it is easy to specify the location , size & alignment
If the same property would have for webforms it would be easier for the developer.
Further , It would be great full how to do the number formatting of a text box according
to the indian style like 0:##,##,##,###.00.
Ganesh@.Nilgris:
I did not get this idea.
Thanks.
I created some variables in the code file and i called this variables using <%= txtname %>
the values are getting empty when the postback happens, i have declared the variables
below the class file ?
What should i do to retain the values ?
Standard variables created on class should use ViewState in order to preserve their state over postbacks. Reason is simple. Page class and controls are recreated for each request (also postback) so they are initialized to defaults.
Instead of using say
private int SampleInteger = 0;
Use a property
protected int SampleIntegerProperty
{
get
{
int retVal = 0;
object obj = ViewState["SampleIntegerProperty"];
if (obj != null)
{
retVal = (int)obj;
}
return retVal;
}
set
{
ViewState["SampleIntegerProperty"] = value;
}
}
Ganesh@.Nilgris:
2. I want to format the numbers like ##,##,##,###.00 ?. I have given it but the numbers
are not getting formatted in the textbox .
You can use String.Format.http://msdn2.microsoft.com/en-us/library/b1csw23d.aspx
I require a urgent solution for formatting the number , but the hyperlink is not giving a rigid answer.
Please help
Ganesh@.nilgris
TextBox align=right?
Is there a way to right align the text in a textbox?
The task is to edit numbers in a table-column, and it looks kind of silly
with the numbers left-aligned.
A label respond to formatting of the table cell, but text within the texbox
doesn't.
Bjorn"Bjorn Sagbakken" <bjo-sag@.online.nowrote in message
news:T8idnUbcV6IJ7OPbRVnzvAA@.telenor.com...
Quote:
Originally Posted by
Is there a way to right align the text in a textbox?
<asp:TextBox ID="MyTextBox" runat="server" style="text-align:right;" />
--
http://www.markrae.net
"Mark Rae" <mark@.markNOSPAMrae.netwrote in message
news:O6k2GSmtHHA.3556@.TK2MSFTNGP05.phx.gbl...
Quote:
Originally Posted by
"Bjorn Sagbakken" <bjo-sag@.online.nowrote in message
news:T8idnUbcV6IJ7OPbRVnzvAA@.telenor.com...
>
Quote:
Originally Posted by
>Is there a way to right align the text in a textbox?
>
<asp:TextBox ID="MyTextBox" runat="server" style="text-align:right;" />
Thanks. That worked.
I was looking for something like that but didn't find anything browsing the
properties of the textbox, not even style.
Bjorn
Custom attributes defined on a WebControl's tag would be outputted as-is if
they are not recognized to match any typed property. Although, TextBox does
have Style property, inherited from WebControl and in this case iterating
through TextBox's Style property's keys would show text-align is there if
you specify it declaratively
<asp:TextBox ID="TextBox1" runat="server" style="text-align:right" />
foreach (string key in TextBox1.Style.Keys)
{
//Output the keys
}
--
Teemu Keiski
AspInsider, ASP.NET MVP
http://blogs.aspadvice.com/joteke
http://teemukeiski.net
"Bjorn Sagbakken" <bjo-sag@.online.nowrote in message
news:ufidnZCs671E6OPbRVnzvAA@.telenor.com...
Quote:
Originally Posted by
"Mark Rae" <mark@.markNOSPAMrae.netwrote in message
news:O6k2GSmtHHA.3556@.TK2MSFTNGP05.phx.gbl...
Quote:
Originally Posted by
>"Bjorn Sagbakken" <bjo-sag@.online.nowrote in message
>news:T8idnUbcV6IJ7OPbRVnzvAA@.telenor.com...
>>
Quote:
Originally Posted by
>>Is there a way to right align the text in a textbox?
>>
><asp:TextBox ID="MyTextBox" runat="server" style="text-align:right;" />
>
Thanks. That worked.
I was looking for something like that but didn't find anything browsing
the properties of the textbox, not even style.
>
Bjorn
>
"Teemu Keiski" <joteke@.aspalliance.comwrote in message
news:%23oE8d8ntHHA.5028@.TK2MSFTNGP02.phx.gbl...
Quote:
Originally Posted by
Custom attributes defined on a WebControl's tag would be outputted as-is
if they are not recognized to match any typed property. Although, TextBox
does have Style property, inherited from WebControl and in this case
iterating through TextBox's Style property's keys would show text-align is
there if you specify it declaratively
>
<asp:TextBox ID="TextBox1" runat="server" style="text-align:right" />
>
foreach (string key in TextBox1.Style.Keys)
{
//Output the keys
}
Thanks. If I need to check out other keys, I will remember your tip.
I have some textboxes generated dynamically, and now I have applied a line
like this to each one of them:
ItemValue=New TextBox
ItemValue.Style("text-align")="right"
Bjorn
TextBox align=right?
Is there a way to right align the text in a textbox?
The task is to edit numbers in a table-column, and it looks kind of silly
with the numbers left-aligned.
A label respond to formatting of the table cell, but text within the texbox
doesn't.
Bjorn"Bjorn Sagbakken" <bjo-sag@.online.no> wrote in message
news:T8idnUbcV6IJ7OPbRVnzvAA@.telenor.com...
> Is there a way to right align the text in a textbox?
<asp:TextBox ID="MyTextBox" runat="server" style="text-align:right;" />
http://www.markrae.net
"Mark Rae" <mark@.markNOSPAMrae.net> wrote in message
news:O6k2GSmtHHA.3556@.TK2MSFTNGP05.phx.gbl...
> "Bjorn Sagbakken" <bjo-sag@.online.no> wrote in message
> news:T8idnUbcV6IJ7OPbRVnzvAA@.telenor.com...
>
> <asp:TextBox ID="MyTextBox" runat="server" style="text-align:right;" />
Thanks. That worked.
I was looking for something like that but didn't find anything browsing the
properties of the textbox, not even style.
Bjorn
Custom attributes defined on a WebControl's tag would be outputted as-is if
they are not recognized to match any typed property. Although, TextBox does
have Style property, inherited from WebControl and in this case iterating
through TextBox's Style property's keys would show text-align is there if
you specify it declaratively
<asp:TextBox ID="TextBox1" runat="server" style="text-align:right" />
foreach (string key in TextBox1.Style.Keys)
{
//Output the keys
}
Teemu Keiski
AspInsider, ASP.NET MVP
http://blogs.aspadvice.com/joteke
http://teemukeiski.net
"Bjorn Sagbakken" <bjo-sag@.online.no> wrote in message
news:ufidnZCs671E6OPbRVnzvAA@.telenor.com...
> "Mark Rae" <mark@.markNOSPAMrae.net> wrote in message
> news:O6k2GSmtHHA.3556@.TK2MSFTNGP05.phx.gbl...
> Thanks. That worked.
> I was looking for something like that but didn't find anything browsing
> the properties of the textbox, not even style.
> Bjorn
>
"Teemu Keiski" <joteke@.aspalliance.com> wrote in message
news:%23oE8d8ntHHA.5028@.TK2MSFTNGP02.phx.gbl...
> Custom attributes defined on a WebControl's tag would be outputted as-is
> if they are not recognized to match any typed property. Although, TextBox
> does have Style property, inherited from WebControl and in this case
> iterating through TextBox's Style property's keys would show text-align is
> there if you specify it declaratively
> <asp:TextBox ID="TextBox1" runat="server" style="text-align:right" />
> foreach (string key in TextBox1.Style.Keys)
> {
> //Output the keys
> }
Thanks. If I need to check out other keys, I will remember your tip.
I have some textboxes generated dynamically, and now I have applied a line
like this to each one of them:
ItemValue=New TextBox
ItemValue.Style("text-align")="right"
Bjorn