Showing posts with label wizard. Show all posts
Showing posts with label wizard. 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

Friday, March 16, 2012

Populating a DropDownList with a Data Method Code Wizard

Please help... I am sure most of you guys know the answer to this basic question

I am using the Web Matrix ...Getting Started Manual and am to the

Using a Data Method Code Wizard to Populate a DropDownList.

The question is : When asked to Remove the Button1_Click event code...

How is this done? Do I remove the entire code?? And where is the event code?

Sub Button1_Click(sender As Object, e As EventArgs)
DataList1.DataSource = GetOrderDetails(CInt(TextBox1.Text))
DataList1.DataBind()
End SubIn WebMatrix, new events are automatically hooked up to event handlers declaratively. So, after creating a method that handles a Button webcontrol's OnClick event, you'll have something like this in your HTML view:


<asp:Button id="Button1" onclick="Button1_Click" runat="server" Text="Button"></asp:Button>

In this example, the 'onclick' attribute's value identifies the name of the method that handles this control's Click event.

So, if you want to unhook an method from an event in Web Matrix, the simplest way to do this is to remove the corresponding event's attribute on that control's tag. What you do with the method's code after that is entirely up to you.

Hope this helps!
No..this did not help..but thanks anyway. Could you please go to the following URL and see what I mean.

http://www.asp.net/webmatrix/guidedtour/section4/ddlcodebuilder.aspx

I am 1/3 of the way through the tutorial and I like ASP.Net thus far.