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
text box text wont change
help!!!!!!!!!!!!!You just not checking for post back...like I said in the other thread, post your code (especially your load event code) and I will show you how to use it properly to ensure things like this don't happen.
load event
WebMessage web = Serializer.BinDeSerializer(Server.MapPath(@."Logs\" + Request.QueryString["File"]));
msgTxt.Text = web.Message;
titleTxt.Text = web.Title;
nickTxt.Text = web.Author;
post(edit)button
case "EDIT": {
Debug.WriteLine(titleTxt.Text);
string filename = Server.MapPath(@."Logs\" + Request.QueryString["File"]);
WebMessage oldMsg = Serializer.BinDeSerializer(filename);
if (File.Exists(filename)) {
File.Delete(filename);
}
WebMessage newMsg = new WebMessage(
titleTxt.Text,
msgTxt.Text,
nickTxt.Text,
DateTime.Now,
oldMsg.Comments,
Path.GetFileName(filename));
Serializer.BinSerialize(newMsg, filename);
Response.Redirect("Log.aspx?&Action=POST", true);
break;
where titleTxt,msgTxt,nickTxt are the TextBoxes which arent changing the text
In your page load event, check for Page.IsPostBack.
if (!Page.IsPostBack) {
// Perform your initialization (db calls, etc..)
}
still not working...i dont get what would help checkin if it is postback or not lol..because if it is postback and now is not working then checking for it wont help, if it isnt and isnt working by checking i will not do it work..so *** can i do?
Because we are working in a stateless environment. Everytime a postback occurs, the page_load event fires off before any of the control event(s) that caused the post back. So, if you reset the values in the load event, then in your event handler, you are still dealing with the initial default values.
Change to this:
if (!Page.IsPostBack)
{
WebMessage web = Serializer.BinDeSerializer(Server.MapPath(@."Logs\" + Request.QueryString["File"]));
msgTxt.Text = web.Message;
titleTxt.Text = web.Title;
nickTxt.Text = web.Author;
}
hmm...even with hellswraith code it doesnt work..
Well, the code I posted is the exact same, so it wouldn't work (minus the three lines of code) :rolleyes:
Post your entire code-behind, it's something else..
hmm my page is getting a bit confusing, since its only my 2nd asp.net project and i wasnt expecting for somethings i had to implement..i will make a new architecture for the site and then i will try again and if it doesnt work post it here again..but i need to implement cookies..anyone could answer by other post about cookies plz? :D
tks by ur answers btw
Text box text from dataset
i have dataset with the result and i bind it to datagrid
in datagrid i use to display text for hyperlink
<asp:datagrid
'<%# DataBinder.Eval(Container.DataItem, "ForumName") %>'
</asp:datagrid>
now if i have hyperlink some where on page and i need the text of this hyperlink to show the forumname what user has selected.how to do that.the dataset has the result and i want the ForumName from the dataset to hyperlink which is on the page not in datagrid.
Hello,
The code below creates a GridView control that have a hyperlink column which
sends the ID to other page:
Here is the simple code which you can use:
<asp:GridView ID="GridView1" runat="server" BackColor="White" BorderColor="White"
BorderStyle="Ridge" BorderWidth="2px" CellPadding="3" CellSpacing="1"
GridLines="None" AutoGenerateColumns="False">
<FooterStyle BackColor="#C6C3C6" ForeColor="Black" />
<RowStyle BackColor="#DEDFDE" ForeColor="Black" />
<PagerStyle BackColor="#C6C3C6" ForeColor="Black" HorizontalAlign="Right" />
<SelectedRowStyle BackColor="#9471DE" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#E7E7FF" />
<Columns>
<asp:BoundField DataField="CategoryID" />
<asp:HyperLinkField DataNavigateUrlFields="CategoryID"
DataNavigateUrlFormatString="SmallWindow.aspx?id={0}"
DataTextField="CategoryName" NavigateUrl="SmallWindow.aspx" />
<asp:BoundField DataField="Description" />
</Columns>
</asp:GridView>
So, now when you click the CategoryName you will be redirected to SmallWindow.aspx page.
Text Box to search contents in a Gridview Control
I have seen several examples with a dropdownlist filtering the results in a
gridview.
Is there a way to have information typed in a text box used to filter a
gridview?
I would like to for example search on a persons first name and any first
name that contains the contents of my text box appear in the gridview list.The datasource object selectParameters allows you to use the ControlParamete
r
against a TextBox, e.g.
<asp:ControlParameter ControlID="txtCustomer" Name="CustomerID"
PropertyName="Text" Type="String" />
This sample uses a dropdownlist box:
http://www.webswapp.com/CodeSamples...ridView_2c.aspx
and this sample does the same exact filtering using a TextBox:
http://www.webswapp.com/CodeSamples...ridView_3c.aspx
--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"mimo" wrote:
> Hello,
> I have seen several examples with a dropdownlist filtering the results in
a
> gridview.
> Is there a way to have information typed in a text box used to filter a
> gridview?
> I would like to for example search on a persons first name and any first
> name that contains the contents of my text box appear in the gridview list.[/color
]
Text Box to change on focus... Possible?
Hi i was just wondering if it was possible to change a text boxes default value onFocus... I have a search bar and rather then put next to it search product here I wanted to have written in the text box as default Enter Product Code.. and then when the box is clicked on it clears this text away and has a blank textbox before they begin to type
Thanks in advance for any help given
Hey,
Yes, there are two ways to do it. There is a TextboxWatermarkExtender (in the AJAXControlToolkit), which renders the text and manages that automatically for you, or you can use manual javascript, simply by catching the focus and when the textbox value is equal to the watermark value, clear it. I don't have an example on-hand, but you should be able to find one.
Create a test ASPX and add following:
<form id="form1" runat="server">
<div>
<asp:TextBox ID="TextBox1" runat="server" Text="Enter Here"></asp:TextBox> <br/>
</div>
</form>
<script language="javascript" type="text/javascript">
function ClearValue()
{
document.getElementById("<%=TextBox1.ClientID %>").value = "";
}
</script>
In Code Behind add following:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
TextBox1.Attributes.Add("OnFocus", "javascript:ClearValue();")
End Sub
Hope this will serve the purpose.
Code for the text box:
<input id="txtBox1" type="text" value="Some Default Value" onfocus="ClearTxt();" />
Javascript function to clear default value:
<script type="text/javascript">
function ClearTxt() {
document.getElementById("txtBox1").value = ""
}
</script>
you could use a javascript method like teh one shown here
http://www.urban75.org/tech/q024.html
Thanks alot guys for all the help
try this
tst.Attributes.Add("onFocus","ctrl = document.getElementById('tst');ctrl.value = '';")
replace both occurrences of tst with the name of the textbox
Hi sorry i know this is an old post but I was wondering, I managed to get this working the only little thing is if I click in the box it deletes the text (what I was looking for) but if I dont type anything and click away from the box it's still blank.. I was wondering if there was a way to refill the text box with the default text again
Thanks
Hey,
Attach to the client onblur event, that if the textbox's text length is zero, put the text back in the textbox.
I know I am a strong anti-Javascript developer, but using javascript to set properties of a form control is not a very good idea, especially if you consider accessibility issues. Rather, why not to attach labels to the text box, and/or use tool-tip feature for displaying user information. This is both, dynamic, on focus, as well as Accessible to challanged users.
Again, it is kind of personal opinion, but then you have to think about the accessibility issues at some point of time!
Text Box to a Database to a Label
Hi
Im fairly new to ASP.NET, im using 2.0.
I am trying to develop a page where the user can enter text into a multiline textbox and then when they click enter the text is stored in a Table in an SQLServer DB.
When the page is reloaded the text that was stored is outputed to a Label.
This works ok except for one small problem when I entertext in the text box which is more than one line IE
"Hello
my
name
is
Graham"
It is displayed in the Label as "Hello my name is Graham"
Does anyone know how to keep the text in the form that it was entered in the textboxwhen it is displayed in the Label?
Other wise I will not be able to have paragraghs etc, just one long string.
Thanks Graham
The text entered in the multiline textbox has crlf (Carriage Return Line Feed) for line breaks. When you display in html, you must replace those with <br /> to achieve the similar layout.
Hope it helps,
Joe
Text Box Upper Case
How can I force the user to enter only UPPER CASE letters in a
text box
I tried the following in the form load event but doesn't work
TextBox.Text.ToUpper().
Any help much appreciated.
cheers,
Sunil SabirSunil
try
TextBox.Text = UCase(TextBox.Text)
Hope this helps,
Zeeshan Mustafa, MCSD
"Sunil Sabir" <SunilSabir@.discussions.microsoft.com> wrote in message
news:67A81DCD-87CD-45B8-8FEF-E0DF0035B702@.microsoft.com...
> Dear All,
> How can I force the user to enter only UPPER CASE letters in a
> text box
> I tried the following in the form load event but doesn't work
> TextBox.Text.ToUpper().
> Any help much appreciated.
> cheers,
> Sunil Sabir
Sunil,
Another way, if you want the user to see only upper case in the text box
would be to use a RegularExpressionValidator and set the regular expression
to: [A-Z] which will allow only upper case letters.
Sincerely,
S. Justin Gengo, MCP
Web Developer / Programmer
www.aboutfortunate.com
"Out of chaos comes order."
Nietzsche
"M. Zeeshan Mustafa" <zeeshan@.no-spm.please.zeeshan.net> wrote in message
news:evgx%231eXEHA.808@.tk2msftngp13.phx.gbl...
> Sunil
> try
> TextBox.Text = UCase(TextBox.Text)
> --
> Hope this helps,
> Zeeshan Mustafa, MCSD
>
> "Sunil Sabir" <SunilSabir@.discussions.microsoft.com> wrote in message
> news:67A81DCD-87CD-45B8-8FEF-E0DF0035B702@.microsoft.com...
>
>