Showing posts with label event. Show all posts
Showing posts with label event. Show all posts

Saturday, March 31, 2012

Text Box

Hi,

I have an update button click event like this :

lblmessage.text = txtAuthor.text;

Even though I manually change the data in text box, somehow it does not show on to the label field.Whatever value I put in txtAuthor the label field is empty.

Any help is greatly appreciated. I hope I have framed my question properly.

With the semi-colon after the line, it looks like C#, so, just in case - what language are you using (VB or C#)?

augustwind:

With the semi-colon after the line, it looks like C#, so, just in case - what language are you using (VB or C#)?

I am using C#. Actually the updated data from the textbox goes to the property of an object. But when I found there was a problem I created a label control to see if the data is being read from the text box. But no data is being read from the text box.


Well - I don't really know what to tell you - it definitely should work.

Save it again - and rebuild - then run it, and put a break point at the code line and see if it ever hits that line.


Are u changing the value of the textbox in the page load, because that event is fired first.

Hope this helps

Thanks

Vikram

Vikram's Blog


Are you using Visual Web Developer? I have the same problem sometime when trying to get the values for update/.

Thanks


e_screw:

Are you using Visual Web Developer? I have the same problem sometime when trying to get the values for update/.

Thanks

I am using the Full blown edition of VS. I guess as Vikram suggested I am gonna have to check the code in the page load event.


Thanks a lot for the reply guys. I was able to fix the problem.

The problem was that I was pulling the data from the database in the page load event. And whenever I click the update button the original data from teh DB get loaded due to the page load event firing first. So there was no update taking place. Hence the label control which was pulling the data from the textbox was pulling the original data instead of the updated data... I hope I make sense in what I said.

I fixed it by adding the code for pulling data from the DB inside the " if (! IsPostBack) { } " block within the page load event. That fixed the problem in the test page that I created. I havent yet tested it on other pages that I am having trouble with. Hope fully I have resolved the problem. Thanks to Vikram for pointing out the Page Load event.

Text Box Upper Case

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 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...
>
>

Wednesday, March 28, 2012

Text Changed Event for a button

There are two text box, one is from date and another is to date
textbox. Each text box having a calender popup button to select From
date and To date. Both text box having a TextChanged event
attached.There is one more text box named as No. of Days, No. of days
means the difference b/w from date and to date, to calculate the No. of
Days i have written the code in TextChanged event. When i am entering
date manually in both text box the TextChanged Event is working and i
am getting the no. of days. But when i am selecting a date from
calender popup, then the TextChanged Event is not working and i am not
getting the difference in No. of Days test box.Attach a server OnClick event to the popup button. Then on the server side
take values of From and To dates and calculate No.of Days. You should not
care whether the postback originated from TextChanged or OnClick event.

Eliyahu

"gaurav" <gauravsrivastava2003@.yahoo.com> wrote in message
news:1116421111.732062.97490@.f14g2000cwb.googlegro ups.com...
> There are two text box, one is from date and another is to date
> textbox. Each text box having a calender popup button to select From
> date and To date. Both text box having a TextChanged event
> attached.There is one more text box named as No. of Days, No. of days
> means the difference b/w from date and to date, to calculate the No. of
> Days i have written the code in TextChanged event. When i am entering
> date manually in both text box the TextChanged Event is working and i
> am getting the no. of days. But when i am selecting a date from
> calender popup, then the TextChanged Event is not working and i am not
> getting the difference in No. of Days test box.

text change on click event

Hello all
i have a problem with aspx page that have some textbox and a checkbox .
i put code onCheckBox1_CheckedChangedthat value of first textbox put in second textbox.
if i edit the value of first textbox then value should be update of second textbox.
I cant post the page so want to fire click event. my code is

privatevoid CheckBox1_CheckedChanged(object sender, System.EventArgs e)

{

TextBox2.Text=TextBox1.Text;

}

Is CheckBox1 autopostback set to true?
But if you want the textbox to automatically change the value of the second textbox without the checkbox, then you need to look into some javascript.
Zath

yes autopostback is true.

And i don want to use javascript. plz give me the solution in asp.net or C#.


i donot know if what think is useful but you can try
have you tried to place the code in the textbox event with adding if statement for the checkbox and use auto post back ... and see if that will help??!!!
but i think the JS is better for a client side operations to reduce the traffic on the server !!! let me know what you do!!

What code do you have in your page_load event? Is there anything there that manipulates the text box? remeber that the page_load event fires every time the page posts back.
smtraber
i tried this code in the check box method

IfMe.CheckBox1.Checked =TrueThen

Me.TextBox2.Text =Me.TextBox1.Text

EndIf
and the auto post back is true for the check box
now when i write the text and tick after that i will get the change !!!
Is that what you meant?


Your code is ok and fine
IfMe.CheckBox1.Checked =TrueThen

Me.TextBox2.Text =Me.TextBox1.Text

EndIf
but the problem is that when i change the value of textbox1 (after check clicked )
then also value should be change without post the form.



arvindharitus wrote:

but the problem is that when i change the value of textbox1 (after check clicked )
then also value should be change without post the form.

Unfortunately, you won't be able to have this event fire without posting the form back to the server unless you use javascript. If your textboxes are set to autopostback=true, then the post back and therefore text_changed event should fire as soon as one of your textboxes loses focus.
smtraber


Check out what's the state of the "enableviewstate" property of the controls you are using? If that is false then just change them to true. Smile [:)]

Text Changed Event for a button

There are two text box, one is from date and another is to date
textbox. Each text box having a calender popup button to select From
date and To date. Both text box having a TextChanged event
attached.There is one more text box named as No. of Days, No. of days
means the difference b/w from date and to date, to calculate the No. of
Days i have written the code in TextChanged event. When i am entering
date manually in both text box the TextChanged Event is working and i
am getting the no. of days. But when i am selecting a date from
calender popup, then the TextChanged Event is not working and i am not
getting the difference in No. of Days test box.Attach a server OnClick event to the popup button. Then on the server side
take values of From and To dates and calculate No.of Days. You should not
care whether the postback originated from TextChanged or OnClick event.
Eliyahu
"gaurav" <gauravsrivastava2003@.yahoo.com> wrote in message
news:1116421111.732062.97490@.f14g2000cwb.googlegroups.com...
> There are two text box, one is from date and another is to date
> textbox. Each text box having a calender popup button to select From
> date and To date. Both text box having a TextChanged event
> attached.There is one more text box named as No. of Days, No. of days
> means the difference b/w from date and to date, to calculate the No. of
> Days i have written the code in TextChanged event. When i am entering
> date manually in both text box the TextChanged Event is working and i
> am getting the no. of days. But when i am selecting a date from
> calender popup, then the TextChanged Event is not working and i am not
> getting the difference in No. of Days test box.
>

Thursday, March 22, 2012

Text1_LostFocus event for ASP.NET project

This is my understanding, however I haven't been able to find confirmation in print. So I'm hoping someone will be able to confirm or deny this.

I have an ASP.NET project with a text box on it. When it loses focus, I want to fire the LostFocus event. The Lost_Focus event is unavailable. I assume this is because I have set the text box to run as a server control. Is this correct?

If this is correct, does that mean I have to create some client side scripting to handle this event? If so, what is the best way to accomplish this?

Thanks,

PardoIf your use server side TextBox control, you may try this:


TextBox1.Attributes.Add("onfocusout", "javascript:alert(""Test"")")

Try the onTextChanged event
OnTextChanged="YourRoutine"

- then use AutoPostback="True"

TextArea Selection

Hi All,
I have got a textarea and wnat to select all the contents in it during page_ load event, so that the user does not need to press control + 'A' .
regards,
ssmantha.You would need to use client-side JavaScript to do this.

DJ
Add a RegisterStartupScript(), and put this there:

document.formname.text_area_name.focus();document.formname.text_area_name.select();
Thanks Issue Solved.

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 TextChanged event

I have an asp:TextBox on my page and I've set the OnChange attribute and implemented the TextChanged event handler and it works fine most of the time.

However, if I clear the contents of the text box and then start entering a new value, and I get a drop down list of recently entered values starting with the same letters that I've just entered in the textbox, and I then select one of items from the drop down list the TextChanged event doesn't fire.

Anyway to get around this? Disable the drop down list from ever appearing?

Thanks
Jonyou prbly have autofill on...go to tools -> internet options -> content in your browser and uncheck the autofill properties...

hth