开发者

UpdatePanel, ModalPopupExtender, and enter keypress issues

Have an UpdatePanel that contains 2 panels with default buttons set to listen to enter key presses. That UpdatePanel is the PopupControl for a ModalPopupExtender.

Running into an issue when pressing enter in the modal popup in which the entire page posts back. Any ideas? Here are some code snippets (I've removed the extraneous fields...):

<div runat="server" id="divShippingEstimatorPopup" class="shippingEstimatorModalPopup">
<asp:UpdatePanel ID="upPopup" runat="server">
    <ContentTemplate>
        <asp:Panel runat="server" ID="pnlShippingEstimator" DefaultButton="lnkbtnGetEstimates">
            <div class="title content_title">Shipping Estimator</div>
            <asp:Label runat="server" ID="lblMessage" />
            <table cellpadding="0" cellpadding="0" class="shipping">
                <!-- Removed to shorten code snippet -->
                <tr>
                    <td colspan="2">
                        <div class="buttonHolder">                            
                            <Monarch:LinkButtonDefault runat=开发者_开发知识库"server" ID="lnkbtnGetEstimates" CssClass="button_action button_margin_right" CausesValidation="false">Get Estimates</Monarch:LinkButtonDefault>
                            <asp:LinkButton runat="server" ID="lnkbtnCancel" CssClass="button_secondary button_secondary_fixed" CausesValidation="false">Cancel</asp:LinkButton>
                            <div class="clear"></div>
                        </div>
                        <div class="clear"></div>
                    </td>
                </tr>
            </table>
        </asp:Panel>
        <asp:Panel runat="server" ID="pnlShippingOptions" DefaultButton="lnkbtnSetEstimate">
            <div class="shippingOptionsHolder" runat="server" id="divShippingOptionsHolder">
                <!-- Removed to shorten code snippet -->
                <div class="buttonHolder">
                    <Monarch:LinkButtonDefault runat="server" ID="lnkbtnSetEstimate" CssClass="button_action">Set Estimate</Monarch:LinkButtonDefault>
                    <div class="clear"></div>
                </div>
                <div class="clear"></div>
            </div>
        </asp:Panel>
    </ContentTemplate>
</asp:UpdatePanel>

Keep in mind the LinkButtonDefault is just this:

public class LinkButtonDefault : LinkButton
{
    private const string AddClickScript = "SparkPlugs.FixLinkButton('{0}');";

    protected override void OnLoad(EventArgs e)
    {
        string script = String.Format(AddClickScript, ClientID);
        Page.ClientScript.RegisterStartupScript(GetType(), "click_" + ClientID,
            script, true);
        base.OnLoad(e);
    }
}

Finally, here is the rest of the control:

<asp:UpdatePanel runat="server" ID="upGetEstimate">
    <ContentTemplate>
        <asp:LinkButton runat="server" ID="lnkbtnGetEstimate" CausesValidation="false">Get Estimate</asp:LinkButton>
    </ContentTemplate>
</asp:UpdatePanel>

<ajaxToolKit:ModalPopupExtender ID="shippingEstimatorPopupExtender" runat="server" TargetControlID="lnkbtnFake" PopupControlID="divShippingEstimatorPopup" BackgroundCssClass="monarchModalBackground"></ajaxToolKit:ModalPopupExtender>
<asp:LinkButton runat="server" ID="lnkbtnFake" style="display:none;"/>

<Monarch:PopupProgress ID="popupProgressGetEstimate" runat="server" AssociatedUpdatePanelId="upGetEstimate" />
<Monarch:PopupProgress ID="popupProgressGetEstimates" runat="server" AssociatedUpdatePanelId="upPopup" />

Basically, the user clicks Get Estimate, a progress bar appears while it loads the form, the form shows in a modal popup. I'm guessing this is something simple, but I can't just get the right combination to get this working properly.


First of all try what happens if you use your scriptmanager to register script in the code behind.

I use this method for registering scripts:

public static void RegisterStartupScript(Control c, string script)
{
    if ((ToolkitScriptManager.GetCurrent(c.Page) as ToolkitScriptManager).IsInAsyncPostBack)
        ToolkitScriptManager.RegisterStartupScript(c, c.GetType(), "Script_" + c.ClientID.ToString(), script, true);
    else
        c.Page.ClientScript.RegisterStartupScript(c.GetType(), c.ClientID, script, true);
}

This checks if you have ScriptManager in your page. If it doesn't, it uses the full postback version.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜