Showing posts with label selects. Show all posts
Showing posts with label selects. Show all posts

Wednesday, March 21, 2012

Populate textbox with dropdown selection (in Wizard Control), using javascript

I have a Wizard Control that contains a number of controls:

After the user selects an item from a DropDown, and the control has lostfocus, I need the selected value to pre-populate a TextBox usingjavascript.

If I create a 'new website' and just throw a dropdown list and textbox onto the page the following code works perfectly:

** Default.aspx.vb:

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
DropDownList1.Attributes.Add("onblur", "FillTextbox()")
End Sub

** Default.aspx:

function FillTextbox ()
{
document.getElementById("TextBox1").value=document.getElementById("DropDownList1").value;
}

The above code, however DOESN'T work if the controls are embedded in a wizard control.

Thus, my question is: How do I get the code to work if the DropDown and TextBox controls are in a Wizard Control?

Any help would be much appreciated!

I believe when the control is embedded within another control the actual name that ends up being used includes the parent-control's name, e.g. Parent_mycontrol. Take a look at the source (right click, View Source) when you run the page to find the actual name of the control. You can reference it by that name in your javascript, fillTextbox() function.

Good luck.


You need to find the correct ID for the TextBox control. As suggested by the fellow developer you need to use the View Source and find the correct ID for the TextBox control. Once, you find the correct ID simply use that Id in the javascript function.

Thank you both SO MUCH for your help! That worked like a charm!Big Smile

Populating a datagrid ... how is it done normally?

Hi All ...
I'm writing a small shopping cart app (school assignment) and need to list
all the books that a user selects.
I have created a "BookBasket" object that contains among other things an
arraylist of the user selected books. The "book" object contains isbn,title
price and quantity information.
I'd like to display the contents of the BookBasket in a datagrid control.
I assume that to start with I'd have to iterate through the basket to
identify each books information, but then how do I populate the datagrid
from there?
It seems from what I've read,that it is easier to populate a datagrid from a
datasource, but I don't know how that would relate to what I'm doing.
any clues or links to examples would be much appreciated.
Thanks in advance
Prime.Prime,
There is a plethora of examples on using a datagrid control. Search
google and you will find more than you need. The second article outlines
what kind of datasources a datagrid will accept, an array is a valid data
source so you won't have to write any code to fill another control. The
third snippit supports my last statement.
Hope this helps.
Jared
Here's one to get you started
http://samples.gotdotnet.com/quicks...c_datagrid.aspx
http://msdn.microsoft.com/library/d...nadodataset.asp
You can bind to the following structures if their elements expose public
properties:
a.. Any component that implements the IList interface. This includes
single-dimension arrays
"Prime" <not@.real.address> wrote in message
news:uIhFN$0pEHA.1668@.TK2MSFTNGP14.phx.gbl...
> Hi All ...
> I'm writing a small shopping cart app (school assignment) and need to list
> all the books that a user selects.
> I have created a "BookBasket" object that contains among other things an
> arraylist of the user selected books. The "book" object contains
> isbn,title
> price and quantity information.
> I'd like to display the contents of the BookBasket in a datagrid control.
> I assume that to start with I'd have to iterate through the basket to
> identify each books information, but then how do I populate the datagrid
> from there?
> It seems from what I've read,that it is easier to populate a datagrid from
> a
> datasource, but I don't know how that would relate to what I'm doing.
> any clues or links to examples would be much appreciated.
> Thanks in advance
> Prime.
>
>
Hi Jared,
I think you've helped me before ... thank-you again.
I found the gotdotnet sample very helpful. We are currently using a text
book that is poor by any standard so your assistance is very much
appreciated.
The second sample was good, but we're not allowed to use a database
interface! I originally coded my app that way,but was told that it was
unacceptable. :( I found the database version extremely simple to code.)
Again, thanks for you assistance.
Prime.
"Jared" <ask_me_for_it@.nospam.com> wrote in message
news:10lpaldc1uahra6@.corp.supernews.com...
> Prime,
> There is a plethora of examples on using a datagrid control. Search
> google and you will find more than you need. The second article outlines
> what kind of datasources a datagrid will accept, an array is a valid data
> source so you won't have to write any code to fill another control. The
> third snippit supports my last statement.
> Hope this helps.
> Jared
> Here's one to get you started
>
http://samples.gotdotnet.com/quicks... />
agrid.aspx
>
http://msdn.microsoft.com/library/d...nadodataset.asp
> You can bind to the following structures if their elements expose public
> properties:
> a.. Any component that implements the IList interface. This includes
> single-dimension arrays
> "Prime" <not@.real.address> wrote in message
> news:uIhFN$0pEHA.1668@.TK2MSFTNGP14.phx.gbl...
list
control.
from
>

Populating a datagrid ... how is it done normally?

Hi All ...

I'm writing a small shopping cart app (school assignment) and need to list
all the books that a user selects.

I have created a "BookBasket" object that contains among other things an
arraylist of the user selected books. The "book" object contains isbn,title
price and quantity information.

I'd like to display the contents of the BookBasket in a datagrid control.

I assume that to start with I'd have to iterate through the basket to
identify each books information, but then how do I populate the datagrid
from there?

It seems from what I've read,that it is easier to populate a datagrid from a
datasource, but I don't know how that would relate to what I'm doing.

any clues or links to examples would be much appreciated.

Thanks in advance

Prime.Prime,
There is a plethora of examples on using a datagrid control. Search
google and you will find more than you need. The second article outlines
what kind of datasources a datagrid will accept, an array is a valid data
source so you won't have to write any code to fill another control. The
third snippit supports my last statement.
Hope this helps.
Jared

Here's one to get you started
http://samples.gotdotnet.com/quicks...c_datagrid.aspx

http://msdn.microsoft.com/library/d...nadodataset.asp

You can bind to the following structures if their elements expose public
properties:

a.. Any component that implements the IList interface. This includes
single-dimension arrays

"Prime" <not@.real.address> wrote in message
news:uIhFN$0pEHA.1668@.TK2MSFTNGP14.phx.gbl...
> Hi All ...
> I'm writing a small shopping cart app (school assignment) and need to list
> all the books that a user selects.
> I have created a "BookBasket" object that contains among other things an
> arraylist of the user selected books. The "book" object contains
> isbn,title
> price and quantity information.
> I'd like to display the contents of the BookBasket in a datagrid control.
> I assume that to start with I'd have to iterate through the basket to
> identify each books information, but then how do I populate the datagrid
> from there?
> It seems from what I've read,that it is easier to populate a datagrid from
> a
> datasource, but I don't know how that would relate to what I'm doing.
> any clues or links to examples would be much appreciated.
> Thanks in advance
> Prime.
>
Hi Jared,

I think you've helped me before ... thank-you again.

I found the gotdotnet sample very helpful. We are currently using a text
book that is poor by any standard so your assistance is very much
appreciated.

The second sample was good, but we're not allowed to use a database
interface! I originally coded my app that way,but was told that it was
unacceptable. :( I found the database version extremely simple to code.)

Again, thanks for you assistance.

Prime.

"Jared" <ask_me_for_it@.nospam.com> wrote in message
news:10lpaldc1uahra6@.corp.supernews.com...
> Prime,
> There is a plethora of examples on using a datagrid control. Search
> google and you will find more than you need. The second article outlines
> what kind of datasources a datagrid will accept, an array is a valid data
> source so you won't have to write any code to fill another control. The
> third snippit supports my last statement.
> Hope this helps.
> Jared
> Here's one to get you started
http://samples.gotdotnet.com/quicks...c_datagrid.aspx
>
http://msdn.microsoft.com/library/d...nadodataset.asp
> You can bind to the following structures if their elements expose public
> properties:
> a.. Any component that implements the IList interface. This includes
> single-dimension arrays
> "Prime" <not@.real.address> wrote in message
> news:uIhFN$0pEHA.1668@.TK2MSFTNGP14.phx.gbl...
> > Hi All ...
> > I'm writing a small shopping cart app (school assignment) and need to
list
> > all the books that a user selects.
> > I have created a "BookBasket" object that contains among other things an
> > arraylist of the user selected books. The "book" object contains
> > isbn,title
> > price and quantity information.
> > I'd like to display the contents of the BookBasket in a datagrid
control.
> > I assume that to start with I'd have to iterate through the basket to
> > identify each books information, but then how do I populate the datagrid
> > from there?
> > It seems from what I've read,that it is easier to populate a datagrid
from
> > a
> > datasource, but I don't know how that would relate to what I'm doing.
> > any clues or links to examples would be much appreciated.
> > Thanks in advance
> > Prime.