ModalPopupExtender不适用于Radgrid

时间:2015-09-07 11:56:03

标签: javascript c# asp.net webforms

我有一个带有linkbutton列“Edit”的radgrid。当用户使用Javascript单击“编辑”按钮时,我想调用modalextenderpopup。但它不起作用:

<telerik:RadGrid ID="RadGrid_Search" runat="server" AllowPaging="True" AllowSorting="True" GroupPanelPosition="Top"  PageSize="30" ResolvedRenderMode="Classic" HorizontalAlign="Right" ondeletecommand="RadGrid_Search_DeleteCommand" onitemdatabound="RadGrid_Search_ItemDataBound" oneditcommand="RadGrid_Search_EditCommand">
    <MasterTableView Width="100%"  DataKeyNames="UPC">
        <EditFormSettings>
            <PopUpSettings Modal="true"/>
        </EditFormSettings>
        <Columns>
            <telerik:GridButtonColumn UniqueName="DeleteColumn" Text="Delete"  CommandName="Delete" ConfirmText="AA">    </telerik:GridButtonColumn>
            <telerik:GridButtonColumn UniqueName="EditColumn" Text="Edit" CommandName="Select" >    </telerik:GridButtonColumn>
        </Columns>
    </MasterTableView>
    <ClientSettings>
        <Selecting AllowRowSelect="True" />
    </ClientSettings>
    <HeaderStyle Font-Bold="True" Font-Names="Verdana" />
    <ItemStyle Font-Names="Verdana" />

</telerik:RadGrid>

<cc1:ModalPopupExtender ID="popup" BehaviorID="popup1" runat="server" DropShadow="false" PopupControlID="pnlAddEdit" TargetControlID="lnkDummy" BackgroundCssClass="modalBackground" OkControlID="btnYes" >
</cc1:ModalPopupExtender>

代码背后:

protected void RadGrid_ItemDataBound(object sender, GridItemEventArgs e)
{
    if (e.Item is GridDataItem)
    {
        GridDataItem dataItem = e.Item as GridDataItem;
        string contactName = dataItem["Album Name"].Text;

        LinkButton button = dataItem["DeleteColumn"].Controls[0] as LinkButton;
        button.Attributes["onclick"] = "return confirm('Are you sure you want to delete " +
contactName + "?')";

        LinkButton btnEdit = dataItem["EditColumn"].Controls[0] as LinkButton;
        btnEdit.Attributes["onclick"] = "return ShowModalPopup()";
    }
}

使用Javascript:

function ShowModalPopup() {
    try
    {
        $find("popup1").show();               
    }
    catch (err) {
    }
    return false;
}

0 个答案:

没有答案