从ModalPopupExtender返回CascadingDropDown SelectedValue [英] Return CascadingDropDown SelectedValue From ModalPopupExtender

查看:61
本文介绍了从ModalPopupExtender返回CascadingDropDown SelectedValue的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在gridview的空数据标签内有一个文本框.在文本框OnClick上,将激活ModalPopupExtender,它显示两(2)个CascadingDropDown控件.

在CascadingDropDown1中选择一个值时,将填充CascadingDropDown2.当我单击确定"按钮时,我希望将CascadingDropDown2中的SelectedValue填充到TextBox_OrderLineItemPart_InsertFirst.Text

我有一个Button_Ok的onclick方法,但它不会触发,它所做的只是给我以下错误:Microsoft JScript运行时错误:"Button_Ok_Click"未定义

我已经无休止地搜索了半天,没有任何解决方法.
感谢您提供的任何帮助.

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.

<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>





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();
}

推荐答案

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


我不知道C#版本是什么,单击一个按钮,然后单击它,然后查看源代码,即可为您提供正确的语法


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


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


我不知道C#版本是什么,点击按钮,然后查看源代码,它将为您提供正确的语法


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


这篇关于从ModalPopupExtender返回CascadingDropDown SelectedValue的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆