locked
Starting ModalPopup from Hyperlink Control and Keeping NavigateURL intact RRS feed

  • Question

  • User-1995187168 posted

    Is it possible to start an event with the hyperlink control?


    For example, when I press the control I need to start a modalpopup.

    I know you may suggest to use a linkbutton but I cannot as I need to start a protocol handler (in the registry) that only starts with a direct link through the hyperlink control.

    So, in my mind it should be something to this effect:

    <

    
    <asp:Hyperlink ID="HyperLink1" runat="server" navigateurl="protocol:handlerpath" click="Hyperlink1">
    
    


    code behind:

    Protected Sub Hyperlink1(ByVal sender as Object, byval e as system.web.ui.imageclickeventargs) handles hyperlink1.click
    
    MyModalPopup.Show()
    
    
    End Sub



    Eh, but of course that doesn't work :)


    Using the targetcontrol for the popup control as a hyperlink renders the hyperlink useless (as it will only open the modal popup) and not go to the navigateurl.

    Any input appreciated.

    Thank you!

    Tuesday, November 18, 2014 9:01 AM

All replies

  • User2103319870 posted

    Add  dummy button in your HTML MarkUp like given below

    <asp:Button ID="btnDummy" runat="server" Text="Edit" Style="display: none;" />

    Assign it to your modalpopup extender

    <asp:ModalPopupExtender ID="mpe" runat="server" DynamicServicePath="" Enabled="True"
            PopupControlID="pnlPopup" BackgroundCssClass="modalBackground" TargetControlID="btnDummy">
        </asp:ModalPopupExtender>

    And open the popup from codebehind like given below

    Protected Sub Hyperlink1(ByVal sender as Object, byval e as system.web.ui.imageclickeventargs) handles hyperlink1.click
    
    MyModalPopup.Show()
    
    
    End Sub

    Tuesday, November 18, 2014 9:29 AM
  • User-1995187168 posted

    Thank you A2H- however hyperlinks do not raise events - so I was just using an example with the Sub  as to what I would like to do.

    Tuesday, November 18, 2014 9:42 AM
  • User1918509225 posted

    Hi akera.moi,

    I suggest that you can set a breakpoint on the hyperlinks ,check if it can be hit.

    Best Regards,

    Kevin Shen.

    Monday, November 24, 2014 4:35 AM