Click here to Skip to main content
15,890,717 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a textbox inside a gridview's empty data tag. On textbox OnClick a ModalPopupExtender is activated which displays two (2) CascadingDropDown controls.

When a value is selected in CascadingDropDown1 then CascadingDropDown2 is populated. When I click the "OK" button I want the SelectedValue from CascadingDropDown2 to be populated into TextBox_OrderLineItemPart_InsertFirst.Text

I have an onclick method for Button_Ok but it won't fire and all it does is give me the following error: Microsoft JScript runtime error: 'Button_Ok_Click' is undefined

I have googled the hell out of this for half a day with no resolution.
Thank-you for any assistance you can offer.

ASP.NET
<EmptyDataTemplate>
    <asp:TextBox runat="server" 
        ID="TextBox_OrderLineItemPart_InsertFirst" 
        ReadOnly="False"/>
    <asp:ModalPopupExtender runat="server"
        ID="ModalPopupExtender_TextBox_OrderLineItemPart_InsertFirst"
        BackgroundCssClass="modalBackground"
        PopupControlID="Panel_PartModal"
        TargetControlID="TextBox_OrderLineItemPart_InsertFirst" 
        OkControlID="Button_Ok" 
        CancelControlID="Button_Cancel" />

    <asp:Panel runat="server" 
        ID="Panel_PartModal" 
        CssClass="modalPopup" 
        style="display:none;">  
        <table>
            <tr>
                <td>
                <asp:Label runat="server"
                    ID="Label11"
                    Text="Vendor:"/>
                </td>
                <td>
                    <asp:DropDownList runat="server"
                        ID="DropDownList_Vendor" />
                </td>
            </tr>
            <tr>
                <td>
                    <asp:Label runat="server"
                        ID="Label10" 
                        Text="Part:" />
                </td>
                <td>
                    <asp:DropDownList runat="server"
                        ID="DropDownList_Part" />
                </td>
            </tr>
        </table>

    <asp:CascadingDropDown runat="server" 
        ID="CascadingDropDown1" 
        TargetControlID="DropDownList_Vendor" 
        Category="Vendor" 
        PromptText="Select vendor" 
        LoadingText="[Loading vendors ...]"
        ServicePath="~/VendorParts.asmx" 
        ServiceMethod="GetVendorList" />

    <asp:CascadingDropDown runat="server"
        ID="CascadingDropDown2"
        TargetControlID="DropDownList_Part"
        Category="Part" 
        ParentControlID="DropDownList_Vendor"
        PromptText="Select part"
        LoadingText="[Loading vendor parts...]"
        ServicePath="~/VendorParts.asmx"
        ServiceMethod="GetPartsForVendor"/>

        <asp:Button runat="server" 
            ID="Button_Ok" 
            Text="Ok" 
            OnClick="Button_Ok_Click" /> 
        <asp:Button runat="server" 
            ID="Button_Cancel" 
            Text="Cancel" /> 
    </asp:Panel>
</EmptyDataTemplate>


C#
public delegate void PartSelectedHandler(string partNumber);
public event PartSelectedHandler PartNumberSelected;

protected void Button_Ok_Click(object sender, EventArgs e)
{
    GridView GridView_Object = GridView_OrderLineItem;
    DropDownList DropDownList_Part_InsertFirst = ((DropDownList)GridView_Object.Controls[0].Controls[0].Controls[0].FindControl("DropDownList_Part_InsertFirst"));
    TextBox TextBox_OrderLineItemPartNumber_InsertFirst = ((TextBox)GridView_Object.Controls[0].Controls[0].Controls[0].FindControl("TextBox_OrderLineItemPartNumber_InsertFirst"));
    PartNumberSelected(DropDownList_Part_InsertFirst.SelectedValue);
    TextBox_OrderLineItemPartNumber_InsertFirst.Text = PartNumberSelected.ToString();
}
Posted
Updated 15-Jun-12 5:48am
v2

OnClick="Button_Ok_Click" 

I don't think you need that in the markup, I think you have to add a handler to the function, to wire them up together
protected void Button_Ok_Click(object sender, EventArgs e) Handles Button_Ok

I don't know what the c# version is, make a button, click on it, and view the source, that will give you the proper syntax
 
Share this answer
 
OnClick="Button_Ok_Click" 

I don't think you need that in the markup, I think you have to add a handler to the function, to wire them up together
protected void Button_Ok_Click(object sender, EventArgs e) Handles Button_Ok

I don't know what the c# version is, make a button, click on it, and view the source, that will give you the proper syntax
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900