简体   繁体   中英

Button firing when I press enter in a textbox

I have a bit of an odd issue. I am using a modal popup and it requires a button but I call it via code.

<ajaxToolkit:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"></ajaxToolkit:ToolkitScriptManager>

<ajaxToolkit:ModalPopupExtender ID="MPE" runat="server"
    TargetControlID="phantomButton"
    PopupControlID="infoPanel"
    CancelControlID="closeInfoPanelButton"
    DropShadow="true">
</ajaxToolkit:ModalPopupExtender>
<asp:Button ID="phantomButton" runat="server" Text="phantomButton" CssClass="phantomButton" />

PhantomButton is hidden via CSS. I have another text box and when enter is pressed it appears to fire the phantom button which causes the popup. Why would this be happening? Also, how do I disable the button so this doesn't happen?

Check the Default Button property of your modal popup panel (or whatever panel your textbox is in). Most likely this property was set to PhantomButton my mistake. If this is the case, whenever that textbox receives focus and enter is pressed, it will trigger your PhantomButton click event. See here for more info on the default button.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM