Saturday, March 31, 2012
Text box TextChangedEvent not firing
the date picker, it fills the textbox with the selected date.Now, i
have a text changed event for the textbox. This event fires only if i
key in a date manually and not if i use the date picker.
How can i make the textchanged event to fire when i use the date
picker?When a date is selected using the date picker and it fills the TextBox, is
this done using a postback or using JavaScript? If it is done using a
postback, the TextChanged event will not be triggered because the text
didn't change since the last postback. If this is the case, here are several
options:
Option #1: Get the date from the datepicker, this way you can get it as a
Date rather than need to worry about converting a String into a Date. If you
want to allow the user to enter the date manually instead, try following
this process (you may need to add a little validation to make sure you do
not get an error converting from String to Date):
1. Get the date from the date picker
2. In the TextChanged event, use the date from the TextBox
Option #2: You can also try using AJAX, which would be my choice.
Option #3: Write your own control.
Good Luck!
--
Nathan Sokalski
njsokalski@.hotmail.com
http://www.nathansokalski.com/
"Sue" <iyer_sansid@.hotmail.com> wrote in message
news:3d8d8c6d-0253-4136-85dc-00a7c24f3ac9@.q78g2000hsh.googlegroups.com...
> I have a textbox box and a date picker.When i select a date through
> the date picker, it fills the textbox with the selected date.Now, i
> have a text changed event for the textbox. This event fires only if i
> key in a date manually and not if i use the date picker.
> How can i make the textchanged event to fire when i use the date
> picker?
>
On 21 Mar, 20:39, Sue <iyer_san...@.hotmail.com> wrote:
> =A0I have a textbox box and a date picker.When i select a date through
> the date picker, it fills the textbox with the selected date.Now, i
> have a text changed event for the textbox. This event fires only if i
> key in a date manually and not if i use the date picker.
> How can i make the textchanged event to fire when i use the date
> picker?
Hi
Only one control can trigger a PostBack at any one time and hence
"fire" it's event handler.
No problem!
If you want a piece of code to be executed on the server in response
to more than one control then write a separate routine to handle it
and then put a statement to call the routine in the event handlers of
each control.
For example:
private void SaveDate(DateTime ADate)
{
//code to save date to datasource or whatever
}
protected TextBox1_TextChanged(object sender, EventArgs e)
{
DateTime inputDate =3D DateTime.Parse(TextBox1.Text);
SaveDate(inputDate);
Calendar1.SelectedDate =3D inputDate;
Calendar1.VisibleDate =3D inputDate;
}
protected void Calendar1_SelectionChanged(object sender, EventArgs e)
{
SaveDate(Calendar1.SelectedDate);
TextBox1.Text =3D Calendar1.Date.ToShortDateString();
}
HTH
Thursday, March 22, 2012
Text value of Dropdown.
you the value and selectedindex will get you the position, but how do you
get the text (it isn't selectedText).
Thanks,
TomHi tshad,
Try this:
yourDropDownList.SelectecItem.Text
Guillermo G.
----
--
Guillermo Gonzlez Arroyave :: MCP ASP.Net C# :: DCE4
"tshad" <tscheiderich@.ftsolutions.com> wrote in message news:OlXi9QVkFHA.146
4@.TK2MSFTNGP14.phx.gbl...
How do you get the selected text of a dropdown box? Selectedvalue will get
you the value and selectedindex will get you the position, but how do you
get the text (it isn't selectedText).
Thanks,
Tom
d1.SelectedItem.Text;
"tshad" wrote:
> How do you get the selected text of a dropdown box? Selectedvalue will g
et
> you the value and selectedindex will get you the position, but how do you
> get the text (it isn't selectedText).
> Thanks,
> Tom
>
>
Is DropDownList.SelectedItem.Value what you're looking for?
-Brock
DevelopMentor
http://staff.develop.com/ballen
> How do you get the selected text of a dropdown box? Selectedvalue
> will get you the value and selectedindex will get you the position,
> but how do you get the text (it isn't selectedText).
> Thanks,
> Tom
>
> Is DropDownList.SelectedItem.Value what you're looking for?
Oh! Indeed, DropDownList.SelectedItem.Text is what you're after. :S
-Brock
DevelopMentor
http://staff.develop.com/ballen
"HARI PRASD BARU" <HARIPRASDBARU@.discussions.microsoft.com> wrote in message
news:CB37336A-6424-4CF5-A175-C5F90A100150@.microsoft.com...
> d1.SelectedItem.Text;
That was it.
I can never seem to remember that when I need it.
I never understood why you have a SelectedValue, but not a SelectedText.
Thanks,
Tom
> "tshad" wrote:
>
Text value of Dropdown.
you the value and selectedindex will get you the position, but how do you
get the text (it isn't selectedText).
Thanks,
TomHi tshad,
Try this:
yourDropDownList.SelectecItem.Text
Guillermo G.
------------------------
Guillermo Gonzlez Arroyave :: MCP ASP.Net C# :: DCE4
"tshad" <tscheiderich@.ftsolutions.com> wrote in message news:OlXi9QVkFHA.1464@.TK2MSFTNGP14.phx.gbl...
How do you get the selected text of a dropdown box? Selectedvalue will get
you the value and selectedindex will get you the position, but how do you
get the text (it isn't selectedText).
Thanks,
Tom
d1.SelectedItem.Text;
"tshad" wrote:
> How do you get the selected text of a dropdown box? Selectedvalue will get
> you the value and selectedindex will get you the position, but how do you
> get the text (it isn't selectedText).
> Thanks,
> Tom
>
Is DropDownList.SelectedItem.Value what you're looking for?
-Brock
DevelopMentor
http://staff.develop.com/ballen
> How do you get the selected text of a dropdown box? Selectedvalue
> will get you the value and selectedindex will get you the position,
> but how do you get the text (it isn't selectedText).
> Thanks,
> Tom
> Is DropDownList.SelectedItem.Value what you're looking for?
Oh! Indeed, DropDownList.SelectedItem.Text is what you're after. :S
-Brock
DevelopMentor
http://staff.develop.com/ballen
Hi tshad,
Try this:
yourDropDownList.SelectecItem.Text
Guillermo G.
------------------------
Guillermo Gonzlez Arroyave :: MCP ASP.Net C# :: DCE4
"tshad" <tscheiderich@.ftsolutions.com> wrote in message news:OlXi9QVkFHA.1464@.TK2MSFTNGP14.phx.gbl...
How do you get the selected text of a dropdown box? Selectedvalue will get
you the value and selectedindex will get you the position, but how do you
get the text (it isn't selectedText).
Thanks,
Tom
d1.SelectedItem.Text;
"tshad" wrote:
> How do you get the selected text of a dropdown box? Selectedvalue will get
> you the value and selectedindex will get you the position, but how do you
> get the text (it isn't selectedText).
> Thanks,
> Tom
>
Is DropDownList.SelectedItem.Value what you're looking for?
-Brock
DevelopMentor
http://staff.develop.com/ballen
> How do you get the selected text of a dropdown box? Selectedvalue
> will get you the value and selectedindex will get you the position,
> but how do you get the text (it isn't selectedText).
> Thanks,
> Tom
> Is DropDownList.SelectedItem.Value what you're looking for?
Oh! Indeed, DropDownList.SelectedItem.Text is what you're after. :S
-Brock
DevelopMentor
http://staff.develop.com/ballen
"HARI PRASD BARU" <HARIPRASDBARU@.discussions.microsoft.com> wrote in message
news:CB37336A-6424-4CF5-A175-C5F90A100150@.microsoft.com...
> d1.SelectedItem.Text;
That was it.
I can never seem to remember that when I need it.
I never understood why you have a SelectedValue, but not a SelectedText.
Thanks,
Tom
> "tshad" wrote:
>> How do you get the selected text of a dropdown box? Selectedvalue will
>> get
>> you the value and selectedindex will get you the position, but how do you
>> get the text (it isn't selectedText).
>>
>> Thanks,
>>
>> Tom
>>
>>
>
TextBox
Hi,
I was wondering how would i be able to use text that is highlighted in a textbox. Say, i wanted to make the selected text bold when the user clicks a button much like the one in this fourm.
I am not sure whether you can do that in a text box. You need to use third party controls. Can you please tell us the scenario for your requirement?
i have a mulitline textbox and say if the user writes a paragraph and wants to bold a line that he or she has selected. How would the code look like if i wanted to bold the selected text when the user clicks a button.
Have you taken a look atFreeTextBox?