Showing posts with label boxes. Show all posts
Showing posts with label boxes. Show all posts

Monday, March 26, 2012

Set defualt date as Week Day before Today.

VB.Net and a simple aspx.net page.

I have this simple code that puts Today's date in these 2 textboxes. Can
some one tell me how to set these two boxes with yesterday's date excluding
weekends?

Thanks!
phil

----------

Dim dtmToday As String

dtmToday = Now.Date.ToString("MM/d/yyy")

TextBox1.Text = dtmToday

TextBox2.Text = dtmTodayThanks, but that didn't work. Your code just took the date back 7 days
INCLUDING WEEKENDS. If the textbox is 12/11/06, it is now 12/4/06. If I
change the code to -1, it will go back one day but it does not disregard the
weekends. How do you disregard the weekends?

"Saubz" <saubz@.newsgroups.nospamwrote in message
news:6FC8AB4E-D0BB-4843-BE0C-3EAB4E576AC7@.microsoft.com...

Quote:

Originally Posted by

Phillip,
>
Try this out
>
>
TextBox1.Text = DateAdd(DateInterval.Day, -7, DateTime.Now)
>
>
>
"Phillip Vong" wrote:
>

Quote:

Originally Posted by

>VB.Net and a simple aspx.net page.
>>
>I have this simple code that puts Today's date in these 2 textboxes. Can
>some one tell me how to set these two boxes with yesterday's date
>excluding
>weekends?
>>
>Thanks!
>phil
>>
>----------
>>
>>
>>
>Dim dtmToday As String
>>
>dtmToday = Now.Date.ToString("MM/d/yyy")
>>
>TextBox1.Text = dtmToday
>>
>TextBox2.Text = dtmToday
>>
>>
>>


On Mon, 11 Dec 2006 18:18:00 -0500, Phillip Vong wrote:

Quote:

Originally Posted by

Thanks, but that didn't work. Your code just took the date back 7 days
INCLUDING WEEKENDS. If the textbox is 12/11/06, it is now 12/4/06. If I
change the code to -1, it will go back one day but it does not disregard the
weekends. How do you disregard the weekends?


Hey Philip,

Try this out. Its not pretty but it works

sub Main
' This should return monday the 11th
Console.WriteLine( _
GetLastBusinessDay(new DateTime(2006,12,12),1))
'This should return friday the 8th
Console.WriteLine( _
GetLastBusinessDay(new DateTime(2006,12,12),2))
Console.ReadLine()
end sub

function GetLastBusinessDay (theDate as DateTime, daysAgo as Integer) as
DateTime
'
' Some local variables
'
dim counter as integer
dim temp as DateTime =theDate
'
' Put in a loop
'
while true
'
' Do some error checking
'
if theDate=DateTime.MinValue
return DateTime.MinValue
end if

'
' Decrement the day
'
temp= temp.AddDays(-1)
'
' Check if it is a weekday
'
select case temp.DayOfWeek
case DayOfWeek.Monday to DayOfWeek.Friday
'
' It is! Increment the counter
'
counter=counter+1
end select
'
' Now check if the counter is equal to
' the days we want
'
if counter=daysago then
return temp
end if

end while
end function
--
Bits.Bytes
http://bytes.thinkersroom.com

Set Focus

How do you set the focus to a text box in ASP .NET? ASP Text boxes don't have a focus or setfocus method.Spot on.
Javascript has a "focus" function call :)

Something likedocument.getElementById('txtUsername').focus();

Saturday, March 24, 2012

set focus in text box

Hi, id like to set focus for a text box in my web form but I dont know how. the text boxes do not have a setFocus or a Focus method

Thanks!!

myTextBox.select(); <<<< JavaScript
we use the following function which injects client side script

PublicSharedSub Set_Focus(ByVal aspPageAs System.Web.UI.Page,ByVal strControlNameAsString)

Try

Dim strScriptAsString

strScript ="<script language=javascript> document.all.item(""" & strControlName &""").focus() </script>"

aspPage.RegisterStartupScript("focus", strScript)

Catch exAs Exception
Throw ex
EndTry
EndSub

following then to call you would simply say:- Set_Focus(Me.Page,"txtMyTextbox")


In .NET 2.0, the Focus() method will set focus if you want to do it from code-beside.

HTH,
Ryan

Set Focus on a control

Hello,

On a click event, I need to test certain text boxes and then based on their
values go to another text box. How do you set the focus using vb?

--
Thanks in advance,

StevenLook at the "Focus in WebForms" thread earlier today...

Set focus on a text box

Dear All,
I have developed a aspx web page with c# as page language. I have place two
text boxes and two requiredfield validator control for each text box. Now
whenever i a text box is null, i want to set the focus on the text box apart
from displaying the error message. Please help.
Regards,
SwamiOne way is to handle the onBlur event of the text box:
<asp:TextBox runat="server" id="txt" onblur="if (this.value.replace(/\s/g,
'').length == 0) this.focus();">
"Swami" <Swami@.discussions.microsoft.com> wrote in message
news:CEB6C427-6924-4D9F-B731-7E560DB05FEC@.microsoft.com...
Dear All,
I have developed a aspx web page with c# as page language. I have place two
text boxes and two requiredfield validator control for each text box. Now
whenever i a text box is null, i want to set the focus on the text box apart
from displaying the error message. Please help.
Regards,
Swami
The easiest, most reliable way is client side java script:
MyControl.focus();
Here's more info:
http://wp.netscape.com/eng/mozilla/...f_f-g.htm#59872
You might also consider using this free control:
http://www.metabuilders.com/Tools/FirstFocus.aspx
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
Hire top-notch developers at http://www.able-consulting.com
"Swami" <Swami@.discussions.microsoft.com> wrote in message
news:CEB6C427-6924-4D9F-B731-7E560DB05FEC@.microsoft.com...
> Dear All,
> I have developed a aspx web page with c# as page language. I have place
> two
> text boxes and two requiredfield validator control for each text box. Now
> whenever i a text box is null, i want to set the focus on the text box
> apart
> from displaying the error message. Please help.
> Regards,
> Swami
Check out this code snippet,
http://www.extremeexperts.com/Net/C...ck.
aspx
Saravana
http://dotnetjunkies.com/WebLog/saravana/
www.ExtremeExperts.com
"Swami" <Swami@.discussions.microsoft.com> wrote in message
news:CEB6C427-6924-4D9F-B731-7E560DB05FEC@.microsoft.com...
> Dear All,
> I have developed a aspx web page with c# as page language. I have place
two
> text boxes and two requiredfield validator control for each text box. Now
> whenever i a text box is null, i want to set the focus on the text box
apart
> from displaying the error message. Please help.
> Regards,
> Swami

Set focus on a text box

Dear All,
I have developed a aspx web page with c# as page language. I have place two
text boxes and two requiredfield validator control for each text box. Now
whenever i a text box is null, i want to set the focus on the text box apart
from displaying the error message. Please help.

Regards,
SwamiOne way is to handle the onBlur event of the text box:

<asp:TextBox runat="server" id="txt" onblur="if (this.value.replace(/\s/g,
'').length == 0) this.focus();"
"Swami" <Swami@.discussions.microsoft.com> wrote in message
news:CEB6C427-6924-4D9F-B731-7E560DB05FEC@.microsoft.com...
Dear All,
I have developed a aspx web page with c# as page language. I have place two
text boxes and two requiredfield validator control for each text box. Now
whenever i a text box is null, i want to set the focus on the text box apart
from displaying the error message. Please help.

Regards,
Swami
The easiest, most reliable way is client side javascript:

MyControl.focus();

Here's more info:
http://wp.netscape.com/eng/mozilla/...f_f-g.htm#59872

You might also consider using this free control:
http://www.metabuilders.com/Tools/FirstFocus.aspx

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
Hire top-notch developers at http://www.able-consulting.com

"Swami" <Swami@.discussions.microsoft.com> wrote in message
news:CEB6C427-6924-4D9F-B731-7E560DB05FEC@.microsoft.com...
> Dear All,
> I have developed a aspx web page with c# as page language. I have place
> two
> text boxes and two requiredfield validator control for each text box. Now
> whenever i a text box is null, i want to set the focus on the text box
> apart
> from displaying the error message. Please help.
> Regards,
> Swami
Check out this code snippet,
http://www.extremeexperts.com/Net/C...erPostback.aspx

--
Saravana
http://dotnetjunkies.com/WebLog/saravana/
www.ExtremeExperts.com

"Swami" <Swami@.discussions.microsoft.com> wrote in message
news:CEB6C427-6924-4D9F-B731-7E560DB05FEC@.microsoft.com...
> Dear All,
> I have developed a aspx web page with c# as page language. I have place
two
> text boxes and two requiredfield validator control for each text box. Now
> whenever i a text box is null, i want to set the focus on the text box
apart
> from displaying the error message. Please help.
> Regards,
> Swami

Set focus on null fields!

Hi,
I have a login form and I have two text boxes in it and the user is required to enter data in the textboxes.If they fail to enter data in any one of the text box and hit the submit button I would like for the cursor to setfocus on the empty text box for the user to enter the data.How would I do this in asp.net.If not would I be able to write Javascript and call the function and where would I call the function.COuld someone expalin how to accomplish this.I do know how to set focus on the first textbox when the page loads up.But I am lost when I am required to setfocus the cursor at the empty text box for user entry?try this:


string strScript = null;
strScript = "<script language=javascript> document.all('TextBox1').focus() </script>";
RegisterStartupScript("focus",strScript);

HI Azam,
I am getting a synatax error. Do I have to declare strScript in my Dim?Also is this a subroutine all by itself or is it part of another subroutine(like page_load)?
Hi,

try to put this code on the Server Side Button Click event.
HI Azam,
I tried your way but I get the error message that says strString is not declared.Also in your code the "TextBox1" would be the ID for the text boxes I have in my project Right?
declare strString as a string variable.

like this:


string strString = "whatever"; // C# syntax

Yes "TextBox1" is the id for the textboxes you have in yr project.
HI Azam,
I am doing this in VB .would the codes be any different if it is VB.
Only syntax.

Here is aC# to VB.NET converter.
HI Azam,
If I did it by your codes would I be able to set focus on the null fields or just the first text box.I am so many error message and that's why I could not see the results.Could you please mail me regarding this?Thanks.
Hi Picky,
Thanks.That is a cool tool!

Tuesday, March 13, 2012

Set Postback or Session Timeout

Hi All.
I have a page that users enter information in text boxes...and
sometimes it's a lot of information. There are times that these folks
either take their time entering the info or do other things before they
submit the page. Unfortunately, if they do take their time, there are
times where the session times out and they can no longer submit their
information, resulting in an error and pretty peeved users.
What I'm asking for help on is...can, possibly through a timer or
something either reset the session or do a postback? This would be to
cover in case the user would take too much time to submit the
information....it would happen automatically. I do have a popup box
that warns them they are about to time out, but it might not be seen.
So far, I have tried a timer to redirect the page to itself, try to go
through the page_load and try to set the session.timeout, but none of
it looks to work. I did see some __doPostBack and Page.GetPostBackEvent
articles, but didn't see how to put them to use. They get mentioned,
but I don't see how to make them function on my page. I need some way
to try to keep the session alive and not timeout. Sorry if it's
something that's easy that I don't see. I'm still a bit (ok, well very)
new at this I have searched Google high and low and found nothing that
looks to work.
Thanks for any help you can be!!
kurtYou can:
1. Extend the length of the session timeout.
2. Store your information in ViewState instead.
"kurt" <kbaker@.granitemicrosystems.com> wrote in message
news:1115834747.970410.207850@.o13g2000cwo.googlegroups.com...
> Hi All.
> I have a page that users enter information in text boxes...and
> sometimes it's a lot of information. There are times that these folks
> either take their time entering the info or do other things before they
> submit the page. Unfortunately, if they do take their time, there are
> times where the session times out and they can no longer submit their
> information, resulting in an error and pretty peeved users.
> What I'm asking for help on is...can, possibly through a timer or
> something either reset the session or do a postback? This would be to
> cover in case the user would take too much time to submit the
> information....it would happen automatically. I do have a popup box
> that warns them they are about to time out, but it might not be seen.
> So far, I have tried a timer to redirect the page to itself, try to go
> through the page_load and try to set the session.timeout, but none of
> it looks to work. I did see some __doPostBack and Page.GetPostBackEvent
> articles, but didn't see how to put them to use. They get mentioned,
> but I don't see how to make them function on my page. I need some way
> to try to keep the session alive and not timeout. Sorry if it's
> something that's easy that I don't see. I'm still a bit (ok, well very)
> new at this I have searched Google high and low and found nothing that
> looks to work.
> Thanks for any help you can be!!
> kurt
>
kurt wrote:
> Hi All.
> I have a page that users enter information in text boxes...and
> sometimes it's a lot of information. There are times that these folks
> either take their time entering the info or do other things before
> they submit the page. Unfortunately, if they do take their time,
> there are times where the session times out and they can no longer
> submit their information, resulting in an error and pretty peeved
> users.
> What I'm asking for help on is...can, possibly through a timer or
> something either reset the session or do a postback? This would be to
> cover in case the user would take too much time to submit the
> information....it would happen automatically. I do have a popup box
> that warns them they are about to time out, but it might not be seen.
>
Maybe you can use a (small) iframe that refreshes itself every few minutes,
to keep the session alive but without submitting the entire page
(and losing scroll-position and focus).
Hans Kesting
Sorry I didn't get back sooner, but I was out for a while. I'm not
sure extending the timeout would work. If I set it to 30 minutes,
they'll probably go 31...and so on. I also wasn't sure that the
viewstate would be usable and last either. But, I did try the iframe
and so far it looks to do exactly as I needed. I also have been trying
it out and I don't look to lose focus from the control I'm currently
using when the iframe refreshes. Thanks for all the input!!
Kurt

Set Postback or Session Timeout

Hi All.
I have a page that users enter information in text boxes...and
sometimes it's a lot of information. There are times that these folks
either take their time entering the info or do other things before they
submit the page. Unfortunately, if they do take their time, there are
times where the session times out and they can no longer submit their
information, resulting in an error and pretty peeved users.

What I'm asking for help on is...can, possibly through a timer or
something either reset the session or do a postback? This would be to
cover in case the user would take too much time to submit the
information....it would happen automatically. I do have a popup box
that warns them they are about to time out, but it might not be seen.

So far, I have tried a timer to redirect the page to itself, try to go
through the page_load and try to set the session.timeout, but none of
it looks to work. I did see some __doPostBack and Page.GetPostBackEvent
articles, but didn't see how to put them to use. They get mentioned,
but I don't see how to make them function on my page. I need some way
to try to keep the session alive and not timeout. Sorry if it's
something that's easy that I don't see. I'm still a bit (ok, well very)
new at this I have searched Google high and low and found nothing that
looks to work.

Thanks for any help you can be!!

kurtYou can:
1. Extend the length of the session timeout.
2. Store your information in ViewState instead.

"kurt" <kbaker@.granitemicrosystems.com> wrote in message
news:1115834747.970410.207850@.o13g2000cwo.googlegr oups.com...
> Hi All.
> I have a page that users enter information in text boxes...and
> sometimes it's a lot of information. There are times that these folks
> either take their time entering the info or do other things before they
> submit the page. Unfortunately, if they do take their time, there are
> times where the session times out and they can no longer submit their
> information, resulting in an error and pretty peeved users.
> What I'm asking for help on is...can, possibly through a timer or
> something either reset the session or do a postback? This would be to
> cover in case the user would take too much time to submit the
> information....it would happen automatically. I do have a popup box
> that warns them they are about to time out, but it might not be seen.
> So far, I have tried a timer to redirect the page to itself, try to go
> through the page_load and try to set the session.timeout, but none of
> it looks to work. I did see some __doPostBack and Page.GetPostBackEvent
> articles, but didn't see how to put them to use. They get mentioned,
> but I don't see how to make them function on my page. I need some way
> to try to keep the session alive and not timeout. Sorry if it's
> something that's easy that I don't see. I'm still a bit (ok, well very)
> new at this I have searched Google high and low and found nothing that
> looks to work.
> Thanks for any help you can be!!
> kurt
kurt wrote:
> Hi All.
> I have a page that users enter information in text boxes...and
> sometimes it's a lot of information. There are times that these folks
> either take their time entering the info or do other things before
> they submit the page. Unfortunately, if they do take their time,
> there are times where the session times out and they can no longer
> submit their information, resulting in an error and pretty peeved
> users.
> What I'm asking for help on is...can, possibly through a timer or
> something either reset the session or do a postback? This would be to
> cover in case the user would take too much time to submit the
> information....it would happen automatically. I do have a popup box
> that warns them they are about to time out, but it might not be seen.

Maybe you can use a (small) iframe that refreshes itself every few minutes,
to keep the session alive but without submitting the entire page
(and losing scroll-position and focus).

Hans Kesting
Sorry I didn't get back sooner, but I was out for a while. I'm not
sure extending the timeout would work. If I set it to 30 minutes,
they'll probably go 31...and so on. I also wasn't sure that the
viewstate would be usable and last either. But, I did try the iframe
and so far it looks to do exactly as I needed. I also have been trying
it out and I don't look to lose focus from the control I'm currently
using when the iframe refreshes. Thanks for all the input!!

Kurt