Showing posts with label date. Show all posts
Showing posts with label date. Show all posts

Monday, March 26, 2012

Populate a Drop Down List

Hello,

i have an ASP.NET / VB page where i have a few 4 groups of Drop Down Lists.
Each group of Drop Down Lists include 3 Drop Down Lists for date such as:
DAY, MONTH, and YEAR.

I don't want to insert the values and text to each drop down list.

So i want to create a script that populates a certain Drop Down List with
certain values when page loads such as:

Day: 1,2,3,4,5,...
Month: January, February, ..., December
Year: 2004, 2003, 2002, 2001, ...

This way in that script i will be able to control how all the Drop Down
Lists are populated just bu changing the script.

Can you help me out?

Thank You,
Miguel

P.S: I am working with ASP.NET / VB.First thing is to remove the word "script" from your vocabulary. VB .NET is
not VBScript.

You could write some code in the .aspx.vb (code-behind) Page_Load event that
will populate the drop down lists by determining today's date (now) and then
use the various methods of the now value to extract the day, month and year.
Then, via looping, you can build up the items on the lists.

"Miguel Dias Moura" <web001@.27NOSPAMlamps.com> wrote in message
news:OyUB0xBUEHA.1012@.TK2MSFTNGP09.phx.gbl...
> Hello,
> i have an ASP.NET / VB page where i have a few 4 groups of Drop Down
Lists.
> Each group of Drop Down Lists include 3 Drop Down Lists for date such as:
> DAY, MONTH, and YEAR.
> I don't want to insert the values and text to each drop down list.
> So i want to create a script that populates a certain Drop Down List with
> certain values when page loads such as:
> Day: 1,2,3,4,5,...
> Month: January, February, ..., December
> Year: 2004, 2003, 2002, 2001, ...
> This way in that script i will be able to control how all the Drop Down
> Lists are populated just bu changing the script.
> Can you help me out?
> Thank You,
> Miguel
> P.S: I am working with ASP.NET / VB.
Create a ListItem. Set the value and the text properties and then add it to
the drop down list. I'm not sure about VB.Net but in C# it would be
something like this:

using System.Globalization;

dtfi = new DateTimeFormatInfo();
for (int month = 1; month < 13; month ++)
{
ListItem li = new ListItem();
li.Text = dtfi.GetMonthName(month);
li.Value = month;
ddlMonth.Items.Add(li);
}

Do basically the same thing for each drop down list. Translating the C# to
VB should be pretty straight forward.

Hope this helps,

Dale

"Miguel Dias Moura" <web001@.27NOSPAMlamps.com> wrote in message
news:OyUB0xBUEHA.1012@.TK2MSFTNGP09.phx.gbl...
> Hello,
> i have an ASP.NET / VB page where i have a few 4 groups of Drop Down
Lists.
> Each group of Drop Down Lists include 3 Drop Down Lists for date such as:
> DAY, MONTH, and YEAR.
> I don't want to insert the values and text to each drop down list.
> So i want to create a script that populates a certain Drop Down List with
> certain values when page loads such as:
> Day: 1,2,3,4,5,...
> Month: January, February, ..., December
> Year: 2004, 2003, 2002, 2001, ...
> This way in that script i will be able to control how all the Drop Down
> Lists are populated just bu changing the script.
> Can you help me out?
> Thank You,
> Miguel
> P.S: I am working with ASP.NET / VB.
One obvious error in my code, make 2nd line:

DateTimeFormatInfo dtfi = new DateTimeFormatInfo();

But then, you have to convert the concept into VB.Net anyway, so it probably
didn't throw you too much.

Good luck

Dale

"DalePres" <don-t-spa-m-me@.lea-ve-me-a-lone--.com> wrote in message
news:uyIxbbCUEHA.1012@.TK2MSFTNGP09.phx.gbl...
> Create a ListItem. Set the value and the text properties and then add it
to
> the drop down list. I'm not sure about VB.Net but in C# it would be
> something like this:
> using System.Globalization;
> dtfi = new DateTimeFormatInfo();
> for (int month = 1; month < 13; month ++)
> {
> ListItem li = new ListItem();
> li.Text = dtfi.GetMonthName(month);
> li.Value = month;
> ddlMonth.Items.Add(li);
> }
> Do basically the same thing for each drop down list. Translating the C#
to
> VB should be pretty straight forward.
> Hope this helps,
> Dale
>
> "Miguel Dias Moura" <web001@.27NOSPAMlamps.com> wrote in message
> news:OyUB0xBUEHA.1012@.TK2MSFTNGP09.phx.gbl...
> > Hello,
> > i have an ASP.NET / VB page where i have a few 4 groups of Drop Down
> Lists.
> > Each group of Drop Down Lists include 3 Drop Down Lists for date such
as:
> > DAY, MONTH, and YEAR.
> > I don't want to insert the values and text to each drop down list.
> > So i want to create a script that populates a certain Drop Down List
with
> > certain values when page loads such as:
> > Day: 1,2,3,4,5,...
> > Month: January, February, ..., December
> > Year: 2004, 2003, 2002, 2001, ...
> > This way in that script i will be able to control how all the Drop Down
> > Lists are populated just bu changing the script.
> > Can you help me out?
> > Thank You,
> > Miguel
> > P.S: I am working with ASP.NET / VB.

Populate a Drop Down List

Hello,
i have an ASP.NET / VB page where i have a few 4 groups of Drop Down Lists.
Each group of Drop Down Lists include 3 Drop Down Lists for date such as:
DAY, MONTH, and YEAR.
I don't want to insert the values and text to each drop down list.
So i want to create a script that populates a certain Drop Down List with
certain values when page loads such as:
Day: 1,2,3,4,5,...
Month: January, February, ..., December
Year: 2004, 2003, 2002, 2001, ...
This way in that script i will be able to control how all the Drop Down
Lists are populated just bu changing the script.
Can you help me out?
Thank You,
Miguel
P.S: I am working with ASP.NET / VB.First thing is to remove the word "script" from your vocabulary. VB .NET is
not VBScript.
You could write some code in the .aspx.vb (code-behind) Page_Load event that
will populate the drop down lists by determining today's date (now) and then
use the various methods of the now value to extract the day, month and year.
Then, via looping, you can build up the items on the lists.
"Miguel Dias Moura" <web001@.27NOSPAMlamps.com> wrote in message
news:OyUB0xBUEHA.1012@.TK2MSFTNGP09.phx.gbl...
> Hello,
> i have an ASP.NET / VB page where i have a few 4 groups of Drop Down
Lists.
> Each group of Drop Down Lists include 3 Drop Down Lists for date such as:
> DAY, MONTH, and YEAR.
> I don't want to insert the values and text to each drop down list.
> So i want to create a script that populates a certain Drop Down List with
> certain values when page loads such as:
> Day: 1,2,3,4,5,...
> Month: January, February, ..., December
> Year: 2004, 2003, 2002, 2001, ...
> This way in that script i will be able to control how all the Drop Down
> Lists are populated just bu changing the script.
> Can you help me out?
> Thank You,
> Miguel
> P.S: I am working with ASP.NET / VB.
>
Create a ListItem. Set the value and the text properties and then add it to
the drop down list. I'm not sure about VB.Net but in C# it would be
something like this:
using System.Globalization;
dtfi = new DateTimeFormatInfo();
for (int month = 1; month < 13; month ++)
{
ListItem li = new ListItem();
li.Text = dtfi.GetMonthName(month);
li.Value = month;
ddlMonth.Items.Add(li);
}
Do basically the same thing for each drop down list. Translating the C# to
VB should be pretty straight forward.
Hope this helps,
Dale
"Miguel Dias Moura" <web001@.27NOSPAMlamps.com> wrote in message
news:OyUB0xBUEHA.1012@.TK2MSFTNGP09.phx.gbl...
> Hello,
> i have an ASP.NET / VB page where i have a few 4 groups of Drop Down
Lists.
> Each group of Drop Down Lists include 3 Drop Down Lists for date such as:
> DAY, MONTH, and YEAR.
> I don't want to insert the values and text to each drop down list.
> So i want to create a script that populates a certain Drop Down List with
> certain values when page loads such as:
> Day: 1,2,3,4,5,...
> Month: January, February, ..., December
> Year: 2004, 2003, 2002, 2001, ...
> This way in that script i will be able to control how all the Drop Down
> Lists are populated just bu changing the script.
> Can you help me out?
> Thank You,
> Miguel
> P.S: I am working with ASP.NET / VB.
>
One obvious error in my code, make 2nd line:
DateTimeFormatInfo dtfi = new DateTimeFormatInfo();
But then, you have to convert the concept into VB.Net anyway, so it probably
didn't throw you too much.
Good luck
Dale
"DalePres" <don-t-spa-m-me@.lea-ve-me-a-lone--.com> wrote in message
news:uyIxbbCUEHA.1012@.TK2MSFTNGP09.phx.gbl...
> Create a ListItem. Set the value and the text properties and then add it
to
> the drop down list. I'm not sure about VB.Net but in C# it would be
> something like this:
> using System.Globalization;
> dtfi = new DateTimeFormatInfo();
> for (int month = 1; month < 13; month ++)
> {
> ListItem li = new ListItem();
> li.Text = dtfi.GetMonthName(month);
> li.Value = month;
> ddlMonth.Items.Add(li);
> }
> Do basically the same thing for each drop down list. Translating the C#
to
> VB should be pretty straight forward.
> Hope this helps,
> Dale
>
> "Miguel Dias Moura" <web001@.27NOSPAMlamps.com> wrote in message
> news:OyUB0xBUEHA.1012@.TK2MSFTNGP09.phx.gbl...
> Lists.
as:
with
>

populate calendar

Hello Everyone,

I'm very new to asp.net. I want to populate calendar based on given date, e.g. if date is 7/11/05, I want to populate calendar from 11 to 31 and showing month on the top. Can please someone give me an idea how should I start it? Is there any built in function for it? I don't need code for it. I would appreciate if someone could tell me how should I start working on it?
Thank you

Hi,
start fromCalendar.SelectedDates

Wednesday, March 21, 2012

populate txtbox

I need to populate a txtbox using client side code. In txtbox1 I let the user select a date and I want to populate txtbox2. I want to do this on the client side, so txtbox2 is automatically populated without having to post back the page. This is how I was thinking about doing it. In the onTextChanged event in txtbox1, I'll call a javascript procedure to place this value in txtbox2...

txtbox2 = DateAdd(DateInterval.Day, 1, CDate(txtbox1.Text))

Is this the proper way to do this? Does anyone have an example?

thanks,
eyeI've used javascript but I normally find some code examples that I can adapt so I can't remember the exacxt way to do what you want. If you look at some javascript sites you should find it easily enough.

populating a drop down list based on the date

Hi, I'm looking to populate a drop down list with the month and year for the next 12 months from the current date, codeing in C#

any help would be great, thanks

this will show the next 12 months in a textbox, not to hard for you to convert to a drop down list

 DateTime date =new DateTime(2007, 02, 11);for (int i = 1; i <= 12; i++) { txtOutput.Text += date.AddMonths(i).ToShortDateString() +"\r"; }

check out this code below... its working for me...

protected void Button2_Click(object sender, EventArgs e) {for (int iCount = 0; iCount < 12; iCount++) { DropDownList1.Items.Add(DateTime.Now.AddMonths(iCount + 1).ToString("MMMM"));if (DropDownList2.Items.FindByText(DateTime.Now.AddMonths(iCount + 1).ToString("yyyy")) ==null) DropDownList2.Items.Add(DateTime.Now.AddMonths(iCount + 1).ToString("yyyy")); } }

hope it helps./.

Friday, March 16, 2012

populating a txtbox

I have two txtboxs. Txtbox1 I let the user populate with a date then I want to populate txtbox2 with a date that is 7 days later. I'm using this code in my codebehind page to populate txtbox2, which is working fine.

txtbox2.Text = DateAdd(DateInterval.Day, 7, CDate(txtbox1.Text))

What I want to know, is there a way to have txtbox2 populate as soon as txtbox1 is filled without having to call the page, so the user knows they won't have to fill in the second date?

thanks,
eyeYou will have to use javascript to do it.